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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 319
What's the best way to get this DataOutputStream into a File object?

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