-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Konstantin,

On 12/22/13, 8:54 AM, Konstantin Preißer wrote:
> Note that the reason for a EOFException is slightly different than 
> just reading from a stream when there is no more data present.
> 
> In Java (and .Net), when you read from a Stream which is finished 
> (there is no more data present), read() returns -1. Even when you 
> repeatedly call read(), you will still get -1, but no exception.

> Normally you do just while ((read = input.read(buffer)) > 0) {
> ...} to test for the end of stream/data.

It's important to note for beginners that you want the comparison
operator to be ">=" and not just ">". If you use "0" than you run the
risk of attempting to read from a stream that has stalled and getting
zero bytes (and stopping) when there may future bytes on the stream.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSt50SAAoJEBzwKT+lPKRYClgP/ifi8rNiMQ46G+7YqA6tX9Y6
YNShZN1SPQ3AC6onDjYpxoR5EgDxP+gw48nYUyQdrjt4L7q8osTN3ahicS4ru4L9
EEqRwI9rcxKvhiecUozcZoNhBESes6NVDhJUi8tRSS5l8c+m3wMA5unhcfHKAltM
0P+yQdeobVeNaWFtB1GZQM7ocRB3GJ8oHpnSM1aXo4NOIsVsjKXL9za/z/0wftVg
c7eLUs3UCO4EDGv2VY6E6HLAyW1bUBiOgU+RchPyXfdcslDnH1MhblaOPFdiAKyO
h8tjaPvlzfmKSz5qSGLKOsjAl5PO3Rt+y2KdTwzzetANzSkAl3HR0OEvqzHstnPM
2kaFLkIxUij44aaFQKZ9SAzLES1F51sbU5VrAaiRTILR/NWe7Tst2WcJgL/0kkHa
vGIIpfxGRIgDcAG8XhLEKX8JHZj+vwaQCflJ3Os/yTzSW0HpRv+Dq5HRVruhnue7
os4wnVr0JIMoBvDMfS2W6U/uBbARgJKvQLozRnOqTrGmK2qC/AGH40R8Ax/EYplK
CJvktEc9iCRMexs8C0rKUM7YSnU0fswu3gwYa1lrP6M3rwIjadsp3qKXWDWO7thB
OKeSYogIiIxVLgS98kbN9i1Jb1TT3XWsdCSSUkvPY5UtKlUPM3EvUZpOeZP/EDTS
OtjJydoSZ0SfeYIu+WDj
=rc4j
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to