Saturday 15 March 2014

java - BufferedReader and InputStream wrong read -


I have a big problem reading data from the stream.

I have such code:

  BufferedReader bufferedReader = new BufferedReader (new InputStreamReader (inputStream)); String topic = bufferedReader.readLine (); While ((bytesRead = inputStream.read (array, 0, array.length))! = -1) {// do something with the array of bytes}  

First of all, let me meet The name of the subject, which has expired with one word, after this, I want to read the rest of the figures (I am reading it in section).

The problem is that inputstream.read return -1 is because everything is read in bufferedReader. How can I fix this?

Continue to use the buffer reader and do not let the data read from the side / bottom. Buffer is given to the previous reader so it can be read further and the inputstream is empty.

It's like a pipeline if you start drilling a hole in the middle of it, hope that the oil is already flown with that new hole, so you can get the pipeline in between Can not get it open by opening


No comments:

Post a Comment