I am currently using buffered streams to read some files. Between them, I do some math processing where the character is a byte.
Think:
InputStream input = new FileInputStream(outputname)
input.read(byte[] b,int off,int len)
To write:
OutputStream output = new BufferedOutputStream(
new FileOutputStream(outputname),
OUTPUTBUFFERSIZE
)
output.write((byte)byteinsideaint);
Now I need to add some header data and also support short characters. I want to use DataInputStreamand DataOutputStreamto avoid converting other types to bytes, and I wonder what their performance is.
Do I need to use
OutputStream output = new DataOutputStream(
new BufferedOutputStream(
new FileOutputStream(outputname),
OUTPUTBUFFERSIZE
)
);
to preserve the benefits of data buffering or enough to use
OutputStream output = new DataOutputStream(
new FileOutputStream(outputname)
)
source
share