Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File I/O

 
Sasikanth Malladi
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter,
Thanks for your reply. But which reader?
Sasikanth
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

And use in.readLine().
-Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic