Chapter 22
Stream I/O
In chapter 9 we saw how to use scala.io.Source and java.util.Scanner to read from files. We also saw how we could use java.io.PrintWriter to write out files. In this chapter we will explore the overall structure of the java.io package and see how streams can be used to represent a general approach to input and output. This will set us up in the following chapter to use streams for network communication.
22.1 The java.io Package
The original library for doing input and output in Java was the java.io package. While there is now a java.nio package that can provide higher performance, the original library is still used as a foundation for many other parts of the Java libraries, which makes it worth knowing and understanding. ...
Get Introduction to the Art of Programming Using Scala now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.