J
JM
Why do the Java Reader classes (File/Buffered/Stream) etc .read()
methods return an int not a char?
For example the javadoc for BufferedReader
.... jdk1.6.0_03/docs/api/java/io/BufferedReader.html declares
"public int read()"
and then the javadoc indicates return value as:
"The character read, as an integer in the range 0 to 65535
(0x00-0xffff), or -1 if the end of the stream has been reached"
The only reason I have come up with is that the class wants to
indicate end-of-stream with a -1. Incidentally when did the character
(singular) become two bytes?
I am engineer and not a comp.sci so I'd appreciate some patience in
your reply.
Jonathan
methods return an int not a char?
For example the javadoc for BufferedReader
.... jdk1.6.0_03/docs/api/java/io/BufferedReader.html declares
"public int read()"
and then the javadoc indicates return value as:
"The character read, as an integer in the range 0 to 65535
(0x00-0xffff), or -1 if the end of the stream has been reached"
The only reason I have come up with is that the class wants to
indicate end-of-stream with a -1. Incidentally when did the character
(singular) become two bytes?
I am engineer and not a comp.sci so I'd appreciate some patience in
your reply.
Jonathan