Abstract Windowing Toolkit and Streams
AWT and Streams
The AWT is not a source of streams in Java.
Even AWT components like a TextArea, which provides large amounts of data, return their contents as strings, not streams.
One of the characteristics of a stream is that the bytes have a certain order. Thus streams are not appropriate for components like TextAreas, where the user is allowed to change or delete text more or less at will.
Java Stream should not be used when creating a user interface.
Classes in java.awt and javax.swing Packages
The classes contained in java.awt (Abstract Window Toolkit) provide access to a basic set of GUI (graphical user interface) widgets, as well as classes to provide support for clipboard operations (copying and pasting) and input devices (mice, keyboards, and the like).
Swing provides a collection of classes that builds on top of the Abstract Window Toolkit to extend GUI support with more advanced routines.
Note that Java 8 also introduces a large update for the so called JavaFX technology. JavaFX describes a series of packages aiming to bring rich, graphical applications to a number of devices and web browsers, and is intended to replace Swing in the future, although both Swing and JavaFX will remain in the JRE for some time. Main features of JavaFX include support for modern 3D graphics and web technologies. On the other hand, building applications with JavaFX has a steeper learning curve than Swing, so Swing remains the preferred method for creating user interfaces in most cases for beginners, and for the development of applications that do not require advanced graphical capabilities.
Character Streams versus Byte Streams
Prior to JDK 1.1, the input and output classes (mostly found in the java.io package) only supported 8-bit byte streams. The concept of 16-bit Unicode character streams was introduced in JDK 1.1. While byte streams were supported via the java.io.InputStream and java.io.OutputStream
classes and their subclasses, character streams are implemented by the java.io.Reader and java.io.Writer classes and their subclasses.
Byte Streams and Character Streams
Java defines two types of streams: byte and character. Byte streams provide a convenient means for handling input and output of bytes.
Byte streams are used, for example, when reading or writing binary data. Character streams provide a convenient means for handling input and output of characters. They use Unicode and, therefore, can be internationalized. Also, in some cases, character streams are more efficient than byte streams.
The original version of Java (Java 1.0) did not include character streams and, thus, all I/O was byte-oriented. Character streams were added by Java 1.1, and certain byteoriented classes and methods were deprecated. Although old code that does not use character streams is becoming increasingly rare, it may still be encountered from time to time. As a general rule, old code should be updated to take advantage of character streams where appropriate. One other point: at the lowest level, all I/O is still byte-oriented. The character-based streams simply provide a convenient and efficient means for handling characters.