Input and Output Streams

  • David Parsons


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).


Virtual Machine File Object Output Stream Primitive Type File Class 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Copyright information

© Springer-Verlag London Limited 2012

Authors and Affiliations

  • David Parsons
    • 1
  1. 1.Inst. of Information and Math. SciencesMassey UniversityAlbany, AucklandNew Zealand

Personalised recommendations