This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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[] 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: 319
What's the best way to get this DataOutputStream into a File object?

I agree. Here's the link:
subject: SequenceInputStream performance
Similar Threads
How to read character stream and byte stream at the same time?
PDF writing woes
Unable to download small sized PDF files properly
get jpeg file from socket stream
Problem in setBinaryStream when using SequenceInputStream