aspose file tools*
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
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "SequenceInputStream performance" Watch "SequenceInputStream performance" New topic
Author

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)
{
out.write(c);
}
s.close();
out.close();
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?

Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SequenceInputStream performance