I'm sending a byte array through a socket and I'm receiving it through a DataInputStream. I don't know the size of the byte array, and there's no way to check. I've tried doing this:
byte[] content = new byte[ARRAY_SIZE];
int something;
while((something = inFromStream.read()) > 0)
output.write(something);
This however, still means that I need to know the size of the byte array. I don't want to just fill in a gigantic number (since the byte array received from the stream could be 100 or maybe even 5000000000). How do I deal with this (preferably with the standard Java API/libraries)?