I had two different modules receiving the inputstream from the
network socket and intended to calculate the number of bytes
received after getting the inputstream. Should I use read for both
instead of one using readLine() ?
Once again, you are talking about bytes, which suggests that your data
is binary, and also about readLine(), which suggests that it is text.
So which is it? Do you want to count bytes or characters?
If your data is *bytes* (i.e. not text), then you should use an
InputStream of some kind. It does not matter which read() method you
use to read the data (mine was only an example).
If your data is *text* then you should use one of the Reader classes.
Be aware that BufferedReader.readLine() and DataInput.readLine() do
not return newline characters, and that conversion from byte to char
can result in fewer chars than bytes, depending on the particular
encoding method used and the actual data sent.
Also, it is generally not so helpful that you talk about methods
without saying which classes they belong to.
The program executed normally except the number of bytes differ by
100 times. I should get 2000 bytes, but the result was 189000 bytes.
I was receiving data from my network socket and it is
DataInputStream.
Perhaps you should post the code where you receive and count the data.
Finally, how do you know that the correct value is 2000?
/gordon