• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Fastest File Read Method

 
Anthony Smith
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading from a file and printing it to a screen.
Currently I do this:

*********************************
What is the fastest way, or at least a faster way?
Keep in mind I only need to read and write ascii with this method, so bascially html & txt files. No binary.
[ April 24, 2002: Message edited by: Dirk Schreckmann ]
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out BufferedReader and BufferedWriter classes.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the Buffered classes at all will give you your first notable improvement - then, figure out how to use the read(char[]) and write(char[], int, int) methods to read/write a group of characters at once. Also, there's no need to build a big String ("thisFile") with all the chars together in it at once - just write each char[] group to your output stream as you go. If you do need to get everything in one big String, try using a StringBuffer instead of String for thisFile.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic