Corrections to Chapter 1 of Java I/O, Introducing I/O

p. 9: In the middle of the page, the arithmetic algorithm given for finding the last byte of the number is incorrect for negative numbers. That section should read like this:

This is the effect of taking the remainder modulo 256 of the int b and adding 256 if the value is negative; that is,

b = b % 256 >= 0 ? b % 256 : 256 + b % 256;

More simply, using bitwise operators,

b = b & 0x000000FF;

p. 10: In the line of code near the top of the page the greater than sign should be greater than or equals; that is,

 int unsignedByte = signedByte >= 0 ? signedByte : 256 + signedByte;
p. 10: In the fifth paragraph change "the absolute value of the number" to "The absolute value of a negative number"

p. 13: EBCDIC is more often an eight-bit character set than a seven-bit set (but only IBM knows for sure in all the different versions of EBCDIC that exist)

p. 21: In the second paragraph of the System.out section change "Hello World" to "Hello World!"

p. 23: In the first paragraph on the page, change

For example, if the user types "Hello World", the following bytes will be read from System.in in this order:
to

For example, if the user types "Hello World!" and hits the return or enter key, the following bytes will be read from System.in in this order:

[ Java I/O Corrections | Java I/O Home Page | Table of Contents | Examples | Order from Amazon ] ]

Copyright 1999 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified August 6, 1999