wood burning stoves 2.0
The moose likes I/O and Streams and the fly likes SequenceInputStream performance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "SequenceInputStream performance" Watch "SequenceInputStream performance" New topic

SequenceInputStream performance

Marshall B Thompson
Ranch Hand

Joined: Apr 11, 2002
Posts: 42
I'm using a SequenceInputStream to read multiple files and merge them together into one file. This is way slow. I'm guessing due to buffering. How do I properly buffer with a SequenceInputStream. My code is below. Note that I'm buffering output, but not input. I tried using s.read(byte[] b, int off, int len) but my output was wacked, I apparantly did not use it properly.

FileOutputStream out = new FileOutputStream(strMergedFilePathAndName);
BufferedOutputStream dest = new BufferedOutputStream(out, m_intBufferSize);

while ((c = s.read()) != -1)
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
This snippet is working well.

Try no to use any buffering at all for speed. I think the OS is is already doing buffering for us.

SCJP2. Please Indent your code using UBB Code
Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 327
What's the best way to get this DataOutputStream into a File object?

I agree. Here's the link: http://aspose.com/file-tools
subject: SequenceInputStream performance
It's not a secret anymore!