1. The character stream
stream of data operation is not particularly convenient Chinese (1) byte, the stream conversion appeared.
Role is to convert the flow of the byte stream into a stream of characters to use.
(2) converting a character stream flow is actually
character stream + = byte stream encoding table
(3) code table
A: is a numeric value corresponding to the characters and a table consisting of
B: common coding table
ASCII ISO-8859-1 UTF-GBK GB18030. 8 GB2312
C: coding problem string
encoding
string - byte []
decoded
byte [] - string
(. 4) in the IO stream coding problem
a: the OutputStreamWriter
the OutputStreamWriter (the OutputStream OS): default encoding, GBK
OutputStreamWriter (OutputStream os, String charsetName) : specify the encoding.
B: InputStreamReader
InputStreamReader (InputStream IS): default encoding, GBK
InputStreamReader (InputStream IS, String charsetName): specify the encoding
C: coding problem is very simple
As long as the same coding can
(5) the character stream
Reader
| --InputStreamReader
| --FileReader
| --BufferedReader
Writer
| --OutputStreamWriter
| --FileWriter
| --BufferedWriter
(6) Copy the text file (5 ways)
2. IO streams Summary
IO streams
| - byte stream
| - input stream of bytes
the InputStream
int Read (): read one byte
int read (byte [] bys) : read one byte array
| - -FileInputStream
| --BufferedInputStream
| - byte output stream
the OutputStream
void write (by int): time to write a byte
void write (byte [] bys, int index, int len): a write array portion of a byte
| --FileOutputStream
| --BufferedOutputStream
| - character stream
| - character input stream
Reader
int the read (): read one character
int read (char [] chs) : once read an array of characters
| --InputStreamReader
| - -FileReader
| --BufferedReader
String readLine (): read one string
| - character output stream
Writer
void the Write (int CH): time to write a character
void write (char [] chs, int index, int len): the first to write a character array part
| --OutputStreamWriter
| --FileWriter
| --BufferedWriter
void newLine (): write a newline
void write (string line): time to write a string
3. Case
A: 5 ways to copy text file
B: Copy image (binary data stream) in four ways
C: the set of data is stored into a text file
D: the read data in the text file to the collection through the collection and
E : copy single-level folder
F: single-stage copy specified file folder and change the name
to recall batches change the name
G: copy the multi-level folder
H: keyboard input student information in accordance with the total score from high to low is stored in a text file
I : sorting the string in a file and outputs a text file to another
J: analog BufferedReader Reader with unique features
K: analog unique features LineNumberReader