Javaレビュー-I / Oフロー

Javaレビュー
I / Oフロー:
1
1)データフローの方向に応じて:
入力ストリーム、出力ストリーム;
2)データ処理ユニットに応じて:
バイトストリーム、文字ストリーム;
3)機能に応じて:
ノードストリーム、処理ストリーム;

2
java.io. *のすべてのフローは、次の4つのカテゴリから継承されます
ここに画像の説明を挿入します
。3
ノードフロー:データソースから直接データを読み取る;
処理フロー:既存のフローに基づいて、既存のフローを介して処理はプログラムにより強力な機能を提供します読み取りおよび書き込み機能;
4
InputStream

InputSteamを継承するクラスは、プログラムにデータを入力するために使用されます
。入力データの基本単位:バイト(8ビット)

基本的な方法:

int read( ) throws IOException 

int read(byte[ ] buffer) throws IOException

int read(byte[ ] buffer,int offset,int length)throws IOException

void close( ) throws IOException

注:
読み出し方法は、ブロッキング方法であるそれは。
バイトの数は、実際に読み取ら返し、ファイルの終わりに達すると、それは-1を返す。
5
のOutputStream

OutputStreamを継承するクラスは、プログラムが
データを出力するために使用されます。データの単位:バイト(8ビット)

基本的な方法:

int write(int b) throws IOException

int write(byte[ ] b) throws IOException

int write(byte[ ] b,int offset,int length)throws IOException

void flush( ) throws IOException

void close( ) throws IOException

フラッシュはキャッシュをクリアします。つまり、キャッシュされたデータをファイルに書き込みます。クローズとは、一般的なプログラムでファイルを閉じることです。close(
を呼び出してディスクにバッファデータを書き込む前に、flush(を呼び出します。

6
Reader
はReaderクラスを継承し、プログラムに文字を入力するために使用されます。
データの単位は文字(16ビット)です。

基本的な方法

int read( ) throws IOException

int read(char[ ] cbuf) throws IOException

int read(char[ ] cbuf,int offset,int length) throws IOException

void close( ) throws IOException

7
Writer
はWriterのクラスを継承
し、プログラムから文字を出力するために使用されます。データの単位は文字(16ビット)です。
基本的な方法

void write(int c) throws IOException

void write(char[ ] cbuf) throws IOException

void write(char[ ] cbuf,int offset,int length) throws IOException

void write(String string) throws IOException

void write(String string, int offset, int length) throws IOException

void close( ) throws IOException

void flush( )  throws IOException

8
ここに画像の説明を挿入します

おすすめ

転載: blog.csdn.net/timelessx_x/article/details/112058843