About buffer read

hi, I am new to the java.io and had a question about

reading certain bytes into a buffer.

DataInputStream in;

Byte buffer[] = new byte[MAX_BUFFER];

in.read(buffer);

Here I have to predefine MAX_BUFFER in order to

read from a stream, can I know the size of the input

in advance of actually reading.

Thx

Pat

[373 byte] By [pwang2000] at [2007-9-26 2:55:50]
# 1
That would be a trick... What if you read from System.in? There really is no upper limit for the input.If you are reading from a file you can use the length() or size() (don't remember which) method defined in java.io.File.
jsalonen at 2007-6-29 10:46:21 > top of Java-index,Core,Core APIs...
# 2
Actually I am reading from HttpURLConnection's inputstream, I guess then there will not be any size functionavailable
pwang2000 at 2007-6-29 10:46:21 > top of Java-index,Core,Core APIs...