Learning Java eighth week

1. flow classification

1, byte stream: Stream

2, the character stream: Writer, Reader

The input stream: InputStream, Reader

Output streams: OuputStream, Writer

Important byte stream or character stream IMPORTANT: byte streams: byte stream class provides a rich environment for processing byte input / output.

Not only can read binary, you can read the text. Character stream: you can only read text.

Stream classification:

Input stream of bytes: InputStream

Output stream of bytes: OuputStream

Character-input stream: Reader

Character-output stream: Writer

2.InputStream flow

1, public abstract class InputStream see the abstract, it can not be used to create objects.

2. Method:

public abstract int read() throws IOException

public int read(byte b[]) throws IOException 

public int read(byte b[], int off, int len) throws IOException 

public int available () throws IOException // returns the number of valid bytes. When the interview said: Please say the role of available methods: obtain a valid number of bytes. Do not call read () method when the file pointer before the first character, followed by the file size of the characters did not read.

public void close() throws IOException 关闭。

3.OutputStream output stream of bytes

1、public abstract class OutputStream 

2. Method:

public abstract void write(int b) throws IOException

public void write(byte b[], int off, int len) throws IOException 

public void flush () throws IOException clear the cache.

public void close() throws IOException

4. The character input stream Reader

1、public abstract class Reader

2. Method:

 public abstract int read() throws IOException

publi

Guess you like

Origin www.cnblogs.com/ywqtro/p/11407381.html