First, according to the data source (whereabouts) Classification:
1, is the file: FileInputStream, FileOutputStream, (Byte stream) FileReader, FileWriter (character)
2, is byte[]: Bytearrayinputstream, Bytearrayoutputstream (Byte stream)
3, is char[]: CharArrayReader, Chararraywriter (character stream)
4, is String:stringbufferinputstream, Stringbufferouputstream (Byte stream) StringReader, StringWriter (character stream)
5, network Data flow: InputStream, OutputStream, (Byte stream) Reader, Writer (character stream)
Second, according to whether to format the output points:
1. To format the output: PrintStream, PrintWriter
Third, press whether to buffer points:
1, to buffer: Bufferedinputstream, Bufferedoutputstream, (Byte stream) BufferedReader, BufferedWriter (character stream)
Iv. by Data format:
1. binary format (as long as it cannot be determined to be plain text): InputStream, OutputStream and all subclasses with Stream end
2, plain text format (including pure English and Chinese characters or other encoding); reader, writer and all the subclasses of reader, writer
Five, according to the input and output points:
1. Input: Reader, subclass of InputStream type
2. Output: Writer, subclass of OutputStream type
Vi. Special Needs:
1. Conversion class from Stream to Reader,writer: InputStreamReader, OutputStreamWriter
2, object input and output: ObjectInputStream, ObjectOutputStream
3. Interprocess communication: Pipeinputstream, Pipeoutputstream, Pipereader, Pipewriter
4. Merge input: Sequenceinputstream
5, more special needs: Pushbackinputstream, Pushbackreader, Linenumberinputstream, LineNumberReader
The general guidelines for deciding which class to use and its construction process are as follows (regardless of special needs):
First, consider what the most primitive data format is: Principle Four
The second is the input or output: Principle five
Third, do you need to convert the flow: Principle Six 1th
What is the source of data (whereabouts): Principle One
Five, whether to buffer: principle Three (Special note: It is important to pay attention to the readLine () whether there is a definition, what is more than read, write a more special input or output method)
VI, do you want to format the output: Principle two
Principles of using Java IO