Performance DataInputStream \ DataOutputStream

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)
                       )
+5
source share
2 answers

BufferedOutputStream . DataOutputStream ( : ), , OutputStream, , writeInt(), .

write(byte[], int, int) writeUTF(String) byte[]. (, int double).

+7

BufferedOutputStream .

, 2 :

  • java. .
  • ( ). , PipedInputStream PipedOutputStream, , getInputStream() getOutputStream(). Pipe -, , get .
+1

All Articles