• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File Input performance

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java Platform Performance: Chapter 4, I/O
 
Rich Stepanski
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yea, when things slow down at work my post count really climbs
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use BufferedReader and BufferedWriter for character-based files. InputStreams are for binary data.
 
reply
    Bookmark Topic Watch Topic
  • New Topic