Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
Read file
abalfazl hossein
Ranch Hand
Posts: 635
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public static void main(String[] args) throws IOException{ try { BufferedReader br = new BufferedReader( new InputStreamReader( new FileInputStream("mytext.txt"))); String Line; while ((Line = br.readLine()) != null) { System.out.println(Line); } int c; while ((c = br.read()) != -1) { System.out.print("\n hihihi"); System.out.print((char)c); } }
The second while doesn't work , why?
I want to compare and
test
difference between readline and read.
Ulf Dittmer
Rancher
Posts: 43081
77
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
ItDoesntWorkIsUseless
.
The first loop exhausts the input - there's nothing left for the second loop to read.
Pramod P Deore
Ranch Hand
Posts: 633
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Comment for first while loop then you will know how second while loop execute.
Life is easy because we write the source code.....
abalfazl hossein
Ranch Hand
Posts: 635
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Then the solution is that I must create new FileInputStream?
Pramod P Deore
Ranch Hand
Posts: 633
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You may also create new BufferedReader to read from the top.
Life is easy because we write the source code.....
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
BufferedReader contents into Array
file2String faster code
bufferedwriter/filewriter...
What's wrong with the program?
How to Read a Flat File Data
More...