A stream is an ordered sequence of bytes flowing from a source to a destination. The implementation of Streams in Java aims to encapsulate any kind of serial input or output into a library of classes that provide a consistent set of abstractions (interfaces and abstract classes), regardless of the source or the sink (destination) of the data. The lower-level details specific to those types of source or destination are handled by the stream, and do not have to be handled by the programmer. For example, the differences between writing to a file and writing to the screen console are handled by the implementations of the relevant classes. From a programmer’s perspective, all we have to do is create an object of the appropriate type of stream class and use its methods. A program may write and read data to and from files, the console, the keyboard, networks, or other programs, all using similar methods, implemented by stream library classes that encapsulate the low-level differences between the various types of data transfer, providing higher-level abstractions for the programmer to use (Fig. 13.1).