Home : Course Map : Chapter 9 : Java :
Input/Output Streams
JavaTech
Course Map
Chapter 9

Introduction
Overview
Streams
Wrappers,Buffers
Console I/O
  Text Output 
     Demo 1

  Formatter/printf()
     Demo 2

  Tex 2t Input
     Demo 3

  Scanner
     
Demo 4
File Class
  File I/O
  File Output-Text
     Demo 5

  Formatter to File
     Demo 6

  File Input - Text
    Demo 7

  Scanner - Files
     Demo 8

  File I/O - Binary
     Demo 9
   Demo 10
File Chooser Dialog
  Demo 11

Character Codes
  Demo 12
   Demo13
Object I/O
Types to Bytes
Stream Filters
Other I/O Topics
Exercises

    Supplements
Character I/O
  Demo 1   Demo 2
Random Access
  Demo 3
ZIP/GZIP Streams
  Demo 4
Piped Streams
  Demo 5
NIO Framework
More NIO
  Demo 6

     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

The central building block of the Java I/O framework is the stream:

Stream = One way sequential flow of bytes

Input operations begin by opening a stream from the source and using a read() method (there are typically several overridden and overloaded read methods) to obtain the data via the stream. Similarly, output operations begin by opening a stream to the destination and using a write() to send the data (similarly, there are typically several overridden and overloaded write methods) .

The base stream classes are the abstract classes:

InputStream   - byte input stream base class
OutputStream - byte output stream base class

Reader             - 16-bit character input stream base class
Writer             - 16-bit character output stream base class

The Reader/Writer classes were added in Java 1.1 to deal with 16-bit character encoding (Unicode) of text. Classes that inherit these abstract classes provide specialized streams such as for keyboard input, file I/O, etc.

The Java I/O classes either extend or wrap lower level classes to provide additional capabilities. See the java.io package specifications for a list of its many stream and ancillary classes.

With Java 1.4 came new packages, including java.nio and java.nio.channels, that add still more I/O related classes. We briefly discuss the java.nio (New IO) classes in the Chapter 9: Advanced section.

In fact, a frequent criticism of Java I/O is that it involves too many classes (see the Class Hierarchy diagram). Often an entire class, such as PushbackInputStream, which puts data back into the stream, is required to do a task that might well have been done by a method within another class.

References & Web Resources

 

Latest update: Nov. 10, 2004

              Tech
Histogram I/O
Hist I/O - Get/Set
  Demo 1
Hist I/O - Objects
  Demo 2
HistogramStream
  Demo 3
Filtering Data
  Demo 4
Exercises

           Physics
Physics Model
Simulation Design
Physics Simulator
  Demo 1
Experiment Design
Experiment Sim.
  Demo 2
Analysis
Expt. + Analysis
  Demo 3
Exercises

  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.