Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

best method to read a long file

 
Gaurav-new-to-java
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , what the best method to read a file ( really really long )
 
Sam Moran
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are talking about a text file you have to read it line-by-line no matter what!

I hope this helps?!?!?
[ October 17, 2002: Message edited by: Sam Moran ]
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sam Moran:
If you are talking about a text file you have to read it line-by-line no matter what!

Actually you can read files in whatever size chunks you want -- lines or no lines, text or binary. Readers should only be used for text, and InputStreams can be used for anything. You can consult the java documentation for details on their usage. Here's a common idiom:
 
Steve Deadsea
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best way to read a file of any size is using buffers. You can either use a buffered wrapper class or do the buffering yourself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic