Java Streams
Like all programming languages, Java has a way for programs to make use
of the data streams provided by the operating system. Java's streams are
defined in the java.io package.
Here are references to several online book chapters that review using Java streams, mostly for file I/O.
- Chapter 11: Files and Streams (PDF) from Java Java Java
- Chapter 2, Input and Output from Core Java, Volume II--Advanced Features, 11th Edition
- Section 11.1, I/O Streams (PDF) (Source code)
- Chapter 7, Input/Output from Java Language Features
- Chapter 11, Saving and Loading Information (code)from Carleton University
- Chapter 6, Streams and File/Device I/O (code) from Carleton University
- I/O Streams from the Java Tutorials
NOTE: The Java language now has two very different kinds of object that
are called "streams". There are the traditional I/O streams that we introduce
in this document. In addition, starting in Java 8, Java defined a Stream
class that is an implementation of the Stream abstract data type, an idea that
comes from functional programming languages. The new Stream class is not for
doing I/O. The new Stream class provides a modern way to process data
structures from the Java Collections Framework.
- https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/stream/package-summary.html
- https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/package-summary.html
Here are the basic "stream" classes in Java. You can see that the
java.util.stream.Stream class is nothing like the java.io.InputStream
or java.io.OutputStream classes.
- https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/InputStream.html
- https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/OutputStream.html
- https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/stream/Stream.html
The Stream abstract data type is becoming an important part of modern programming languages. It plays a big part in modern Java.