ByteArrayInputStream ByteArrayOutputStream Use these streams to read from and write to memory. You create these streams on an existing array and then use the read and write methods to read from or write to the array. StringReader StringWriter Use StringReader to read characters from a String in memory. Use StringWriter to write to a String. StringWriter collects the characters written to it in a StringBuffer, which can then be converted to a String.
StringBufferInputStream StringBufferInputStream is similar to StringReader, except that it reads bytes from a StringBuffer.
Pipe PipedReader PipedWriter
PipedInputStream PipedOutputStream Implement the input and output components of a pipe. Pipes are used to channel the output from one thread into the input of another. See PipedReader and PipedWriter in action in the section How to Use Pipe Streams.
File FileReader FileWriter
FileInputStream FileOutputStream Collectively called file streams, these streams are used to read from or write to a file on the native file system. The section How to Use File Streams. has an example that uses FileReader and FileWriter to copy the contents of one file into another.
Concatenation N/A
SequenceInputStream Concatenates multiple input streams into one input stream. The section How to Concatenate Files. has a short example of this class.
Object Serialization N/A
ObjectInputStream ObjectOutputStream Used to serialize objects. See Object Serialization.
Data Conversion N/A DataInputStream DataOutputStream Read or write primitive data types in a machine-independent format. See How to Use DataInputStream and DataOutputStream. shows an example of using these two streams.
Counting LineNumberReader
LineNumberInputStream Keeps track of line numbers while reading.
Peeking Ahead PushbackReader
PushbackInputStream These input streams each have a pushback buffer. When reading data from a stream, it is sometimes useful to peek at the next few bytes or characters in the stream to decide what to do next.
Printing PrintWriter
PrintStream Contain convenient printing methods. These are the easiest streams to write to, so you will often see other writable streams wrapped in one of these.
Buffering BufferedReader BufferedWriter
BufferedInputStream BufferedOutputStream Buffer data while reading or writing, thereby reducing the number of accesses required on the original data source. Buffered streams are typically more efficient than similar nonbuffered streams and are often used with other streams.
Filtering FilterReader FilterWriter
FilterInputStream FilterOutputStream These abstract classes define the interface for filter streams, which filter data as it's being read or written. The section Working with Filter Streams shows you how to use filter streams and how to implement your own.
Converting between Bytes and Characters InputStreamReader OutputStreamWriter A reader and writer pair that forms the bridge between byte streams and character streams. An InputStreamReader reads bytes from an InputStream and converts them to characters, using the default character encoding or a character encoding specified by name. An OutputStreamWriter converts characters to bytes, using the default character encoding or a character encoding specified by name and then writes those bytes to an OutputStream. You can get the name of the default character encoding by calling System.getProperty("file.encoding").
Memory
CharArrayReader
CharArrayWriter
ByteArrayInputStream
ByteArrayOutputStream
Use these streams to read from and write to memory. You create these streams on an existing array and then use the read and write methods to read from or write to the array. StringReader
StringWriter
Use StringReader to read characters from a String in memory. Use StringWriter to write to a String. StringWriter collects the characters written to it in a StringBuffer, which can then be converted to a String.
StringBufferInputStream
StringBufferInputStream is similar to StringReader, except that it reads bytes from a StringBuffer.
Pipe
PipedReader
PipedWriter
PipedInputStream
PipedOutputStream
Implement the input and output components of a pipe. Pipes are used to channel the output from one thread into the input of another. See PipedReader and PipedWriter in action in the section How to Use Pipe Streams.
File
FileReader
FileWriter
FileInputStream
FileOutputStream
Collectively called file streams, these streams are used to read from or write to a file on the native file system. The section How to Use File Streams. has an example that uses FileReader and FileWriter to copy the contents of one file into another.
Concatenation
N/A
SequenceInputStream
Concatenates multiple input streams into one input stream. The section How to Concatenate Files. has a short example of this class.
Object Serialization
N/A
ObjectInputStream
ObjectOutputStream
Used to serialize objects. See Object Serialization.
Data Conversion
N/A DataInputStream
DataOutputStream
Read or write primitive data types in a machine-independent format. See How to Use DataInputStream and DataOutputStream. shows an example of using these two streams.
Counting
LineNumberReader
LineNumberInputStream
Keeps track of line numbers while reading.
Peeking Ahead
PushbackReader
PushbackInputStream
These input streams each have a pushback buffer. When reading data from a stream, it is sometimes useful to peek at the next few bytes or characters in the stream to decide what to do next.
Printing
PrintWriter
PrintStream
Contain convenient printing methods. These are the easiest streams to write to, so you will often see other writable streams wrapped in one of these.
Buffering
BufferedReader
BufferedWriter
BufferedInputStream
BufferedOutputStream
Buffer data while reading or writing, thereby reducing the number of accesses required on the original data source. Buffered streams are typically more efficient than similar nonbuffered streams and are often used with other streams.
Filtering
FilterReader
FilterWriter
FilterInputStream
FilterOutputStream
These abstract classes define the interface for filter streams, which filter data as it's being read or written. The section Working with Filter Streams shows you how to use filter streams and how to implement your own.
Converting between Bytes and Characters
InputStreamReader
OutputStreamWriter
A reader and writer pair that forms the bridge between byte streams and character streams.
An InputStreamReader reads bytes from an InputStream and converts them to characters, using the default character encoding or a character encoding specified by name.
An OutputStreamWriter converts characters to bytes, using the default character encoding or a character encoding specified by name and then writes those bytes to an OutputStream.
You can get the name of the default character encoding by calling System.getProperty("file.encoding").
详细请参见
http://java.sun.com/docs/books/tutorial/essential/io/datasinks.html
流有多重要?它是Java IO的核心,Java 的IO是Java网络开发的基础,
网络技术是Java的核心,它是几乎所有Java 技术的基础。
包括J2EE/EJB/JMS, Corba, RMI等等.
如果你Java学了很长时间还不熟悉使用流,那么可以说你的Java基础是不扎实的。
虽然Java的IO看起来很烦杂,但是脉络比较清晰,
分字符类和字节类两种。
河水里面有nnn多水分子
而水分子都是由0或者1组成的