Stream is the most basic division: 1. Source Stream is actually the Input Stream 2. Sink Stream is actually Output Stream. Therefore, Stream is a stream of streaks and Sinks belongs to Node Streams. The basic stream includes two Category: ------------------------------------------------------------------------------ ------- | | BYTE streams | Character streams | | --------------------------------- ----------------- | | Source streams | InputStream | Reader | ---------------- - ------------- ------------------- | | Sink Streams | OutputStream | Writer | ------- ---------- ------------- --------------- byte streams class Supported data for RAW BYTES Character Streams class support operations to Unicode Characters Therefore, use Character Streams to use the Character Streams to use the Character Streams to use the CHARACTER Streams to specifically refer to CHARACTER streams. When you see the type name containing InputStream / OutputStream is an operation Byte Stream, you contain Reader / Writer to operate Character Stream) Second, Node Streams Node stream includes three basic classes: Files, Memory, Pipes ----- -------- ------------------------------------------------------------------------------------------------ --- | Type | Character streams | Byte streams | | - ------------ --------------------------------- ------------ | File | FileReader | FileInputStream | | | FileWriter | FileoutputStream | | ------------- --------- --------- ----------------------- | | Memory: array | ChararrayReader | BYTEARRAYINPUTSTREAM | | | ChararrayWriter | ByteArrayoutputstream | ------------- --------------------------------- ---------- | | | | | | | | | ------------- ----------- -------
----------------------- | | PIPE | PIPEDREADER | PIPEDINPUTSTREAM | | | PIPEDWRITER | PIPEDOUTPUTSTREAM | -------------- - -------------------- -------------------- 3, I / O stream chaining IO chain: 1. Input stream chain -------------- ---------------- ---- | | ------------------ | | | | FileInputStream -> | BUFFEREDInputStream -> | DataInputStream | -------- --------------------------------- ------- | | | V ---------- ----- | DataSource | | Program | ---------- ------- 2. Output stream chain ---------- ------- | | ----------------------- | | ------------- --- | DataOutputStream -> | BufferedoutputStream -> | FileOutputStream | | | | -------------- | | ----------- ------------ | ------------------ | A | | V ------- -------- | Program | | DataSink | -------
------ 4, Processing Streams process stream: Processing stream, also called Filter Streams filtering flow (filtering flow) Processing streams can provide Byte streams and character streams to convert ------- ----------- --------------------------------------- ------ | Type | Character streams | | ---------------------------------------------------- -------- ----------------------- | | Buffering | BufferedReader | BufferedInputStream | | | --- ---------------- ------------------- --------- ------------ | | Filtering | FilterReader | FilterInputStream | | (Abstract Class) | FilterWriter | FilterWriter | | ------------------- - ------------------------------------------- | | Converting Between INPUTSTREAMREADER | | | BYTES AND CHARACTER | OuptutStreamWriter | | | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---- ----------------------- | | Object | ObjectInputStream | | Serialization | | ObjectOutputStream | | ---------------------------------------------------------------------------------------------------- - ----------------------- | | Data Conversion | | | | | DataOutputStream | | ----------- --------- ----------------------------------------- ---- | | Counting | LINENUMBERREADER | LINENUMBERINPUTSTREAM | | ------------------------------------------------------------------------------------------------------------------------------------ ---- ----------------------- | | Peeking Ahead | PushbackReader | PushbackInputStream | | ------------ --------
------------------------------------------- | | Printing | PrintWriter | PRINTSTREAM | --------------------------------- ------------------ 5, IO Level IO Hierarchy 1. Basic Byte Stream Class Hierarchy: 1) InputStream Class Hierarchy: --- FileInputStream | - ObjectInputStream --- DataInputStream | | ----------- | ---------------- --- PushbackInputStream | InputStream | <- --- | FilterInputStream | <- | ---------- | ----------------- - - BufferedInputStream | | --- PipedInputStream --- LineNumberInputStream | --- SequenceInputStream | --- StringBufferInputStream | --- ByteArrayInputStream 2) OutputStream class hierarchies: --- FileOutputStream | --- ObjectOutputStream | --- DataOutputStream ------------ | ---------------- | | OutputStream | <- --- | filteroutputstream | <-------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - | | --- PrintStream --- pipedoutputstream | --- ByteaRrayoutputstream 2. Basic Character Stream class hierarchy: 1) Reader class hierarchy: --- BufferedReader <
---- LINENUMBERREADER | --- ChararrayReader | ------ --- StringReader | Reader | <- | ---- --- InputStreamReader <--- FileReader | - PipedReader | --- FilterReader <--- pushbackreader 2) Writer class hierarchy: --- BufferedWriter <--- LinenumberReader | --- ChararRaywriter | --- StringWriter --- --- | | Writer | <- --- OutputStreamWriter <- FileWriter ------ | --- PrintWriter | --- PipedWriter | --- Filterwriter Summary: SL -275 Recommended in the program to use the most underlying subclass to improve efficiency (but I think that the flow input from various Source should require IO chain step by step to translate into the bottom high efficiency IO subclass, the following example is Thus) Sixth, one character flows between objects: 1. Corresponding program: InputStreamReader Reader = new infutStreamReader (system.in); bufferedReader Input = New BufferedReader; string name = input.readline (); System.out.println (Name); 2. Process Schematic: Device (Keyboard) | System.In -> | 65 | 108 | 32 | 7 1 | 111 | 114 | 101 | 13 | ----- InputStream Object | | Reader | ---- | 65 | 108 | 32 | 71 | 111 | 114 | 101 | 13 | <- | InputStreamReader Object | | Input ---> | A | L | | G | O | R | E | / N | --- BufferedReader Object | | Name | ---- "Al Gore" <--- -------- | String Object | | System.out ---> | H | E | L | L | O |, | A | L | | G | O | R | E |! | | --- -