Owl Sams Teach Yourself Java 2 in 21 Days

Day 17: Handling Data Through Java Streams

NOTES AND CORRECTIONS

  • On Page 439, the BufferedReader class is referred to twice as a means of creating output streams. The correct class is BufferedWriter.

SOURCE FILES

READER QUESTIONS

  • Q: The FileWriter class has a write(int) method that's used to send a character to a file. Shouldn't this be write(char)? -- B.B.
    A: The char and int data types are interchangeable in many ways -- you can use an int in a method that expects a char, and vice versa. This is possible because each character is represented by a numeric code which is an integer value. When you call the write() method with an int, it outputs the character associated with that integer value. When calling the write() method, you can cast an int value to a char to ensure that it's being used as intended.

LINKS

  • None