wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes File I/O Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "File I/O" Watch "File I/O" New topic
Author

File I/O

Sasikanth Malladi
Ranch Hand

Joined: Nov 04, 2000
Posts: 175
Hi!
I've got a .txt file with eight lines. Each line contains integers separated by commas. I want to read these numbers. What's the best way of doing it? FileInputStream seems to be pretty unfriendly for this application.
Thanks,
Sasikanth
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783
Use a Reader so you can use a readLine. Pass the String object to a StringTokenizer to get each number.
-Peter
Sasikanth Malladi
Ranch Hand

Joined: Nov 04, 2000
Posts: 175
Peter,
Thanks for your reply. But which reader?
Sasikanth
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783

Use a FileReader chained to a BufferedReader. E.g.

And use in.readLine().
-Peter
 
 
subject: File I/O