File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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[] 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 = != -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:
subject: SequenceInputStream performance
It's not a secret anymore!