Hi Thorsten, I saw nobody ever replied to your message from September.
On Sat, 2005-09-10 at 01:05 +0200, Thorsten Suckow-Homberg wrote: > right now I have some problems with the java.io.BufferedReader and I hope > someone can help out. > > The docblock says about the method read(char[] buf, int offset, int > length): > > * [...] > * This method can > * return before reading the number of chars requested. The actual number > * of chars read is returned as an int. A -1 is returned to indicate the > * end of the stream. > * [...] > > Does this mean that it can happen that the buffer supplied by the caller > doesn't even get filled? No, our documentation also says: * This method will block until some data can be read. > Because I'm operating on some small files and from my understanding there is > a problem with the > default buffersize (BufferedReader::DEFAULT_BUFFER_SIZE = 8192). > > I'll try to explain: I'll try to respond to your analysis. But it is easier if you could supply a self-contained program that doesn't work as you expect with GNU Classpath. Then we can test the behavior ourselves easily. > // the buffer-member of bufferedReader gets filled > // avail is set to -1, since limit equals to 0, and buffer.length-limit > //equals to buffer.length - ergo, the buffer gets filled with the whole > // file-contents > avail = in.read(buffer, limit, buffer.length - limit); No. avail is set to the number of bytes read from in. If everything is read in one go then in.read() returns buffer.length. Only the next call to in.read() would return -1 in that case. Cheers, Mark
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Classpath mailing list Classpath@gnu.org http://lists.gnu.org/mailman/listinfo/classpath