Rusty Elliotte Harold is the God of Java I/O
His excellent first chapter, where he discusses the significance of bytes in InputStream and Output Stream -- how stream read() returns ints but they're ints in the range of 0-255, which is why you can tell an EOF -1 when it appears. Also, difficulties handling bytes, -- and all integer literals in Java are ints ,even when they're in byte range...talk about some of this...
3 FACTS THAT PERTAIN:
1. The byte data type is signed
2. Java always promotes bytes to ints before working on them individually.
3. Many of the methods in the stream classes return or accept as arguments ints in the range of an unsigned byte (0-255).
that means there's a formula you have to apply...
1:35:03 AM
|