How to get size of bytes?

Posted by k80sg on Stack Overflow See other posts from Stack Overflow or by k80sg
Published on 2010-03-23T02:41:06Z Indexed on 2010/03/23 2:51 UTC
Read the original article Hit count: 340

Filed under:

How do I obtain the number of bytes before allocating the byte size of the array 'handsize' as shown below as the incoming ByteArray data are sent in 3 different sizes. Thanks.

BufferedInputStream bais = new  

BufferedInputStream(requestSocket.getInputStream()); 

DataInputStream datainput = new DataInputStream(bais); 

//need to read the number of bytes here before proceeding.

byte[] handsize = new byte[bytesize];  

datainput.readFully(handsize); 

© Stack Overflow or respective owner

Related posts about java