This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: File I/O
 
Similar Threads
Ant error: Make sure you have it in you classpath
requested resource (first.jsp) not available
JMF
Adding a file to a program
File constructor