J
Jan Burse
Dear All
I just notice that there are different buffered reader implementations
around. I am using the int read() method of a BufferedReader instance.
The read() method invokes a fill() method, which will in turn invoke
int read(char[],int,int) of the underlying stream.
The problem arises when the underlying stream returns 0 in the
read(char[],int,int). The harmony implementation does not block:
163 int count = in.read(buf, pos, buf.length - pos);
164 if (count != -1) {
165 end += count;
166 }
http://www.docjar.com/html/api/java/io/BufferedReader.java.html
And together with the logic in read() this will give a random
return value. Which is not good.
Whereby the oracle implementation does block (JDK1.6.0_22), which
is also not good:
134 int n;
135 do {
136 n = in.read(cb, dst, cb.length - dst);
137 } while (n == 0);
138 if (n > 0) {
139 nChars = dst + n;
140 nextChar = dst;
141 }
Is there any way to obtain a buffered reader, so that in both the
harmony implementation and the oracle implementation, read() would
simply return -1?
Bye
I just notice that there are different buffered reader implementations
around. I am using the int read() method of a BufferedReader instance.
The read() method invokes a fill() method, which will in turn invoke
int read(char[],int,int) of the underlying stream.
The problem arises when the underlying stream returns 0 in the
read(char[],int,int). The harmony implementation does not block:
163 int count = in.read(buf, pos, buf.length - pos);
164 if (count != -1) {
165 end += count;
166 }
http://www.docjar.com/html/api/java/io/BufferedReader.java.html
And together with the logic in read() this will give a random
return value. Which is not good.
Whereby the oracle implementation does block (JDK1.6.0_22), which
is also not good:
134 int n;
135 do {
136 n = in.read(cb, dst, cb.length - dst);
137 } while (n == 0);
138 if (n > 0) {
139 nChars = dst + n;
140 nextChar = dst;
141 }
Is there any way to obtain a buffered reader, so that in both the
harmony implementation and the oracle implementation, read() would
simply return -1?
Bye