Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File Input performance  RSS feed

 
Rich Stepanski
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a few massive text files I have to sort through and move. I'm having a seperate thread for each text file use a FileInputStream and several FileWriters to bring the data in, check where it belongs, and then put it there. Is this the best way to handle this? It seems like its rathers slow (old visual basic version of this did all files in 5 minutes- with java single text files are taking 5+). I don't flush any of the writers until the thread is done, and I'm also only reading one line worth of bytes. A JFrame also runs that displays which file its writing to. Any suggestions to speed this up?
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
 
Rich Stepanski
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm starting to think you follow me around this forum solving my problems.. thanks though , haha
 
Rich Stepanski
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've set up a buffered input and output stream now - but how do you get around writing Strings as bytes?
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yea, when things slow down at work my post count really climbs
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but how do you get around writing Strings as bytes?


is what you want? Returns an array of bytes. I've just used this to pass Strings into a zip file output stream. Joe took time off following you around to help me with that one actually, cheers!
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use BufferedReader and BufferedWriter for character-based files. InputStreams are for binary data.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!