자바 검토
I / O 흐름 :
1
1) 데이터 흐름 방향에 따라 :
입력 스트림, 출력 스트림,
2) 데이터 처리 단위에 따라 :
바이트 스트림, 문자 스트림,
3) 기능에 따라 :
노드 스트림, 처리 스트림;
2
java.io. *의 모든 흐름은 다음 네 가지 범주에서 상속됩니다
.3
노드 흐름 : 데이터 소스에서 직접 데이터 읽기,
처리 흐름 : 기존 흐름을 기반으로 기존 흐름을 통해 처리는 프로그램에 더 강력한 기능을 제공합니다. 읽기 및 쓰기 기능,
4
InputStream
InputSteam을 상속받은 클래스는 프로그램에 데이터를 입력하는데 사용됩니다. 입력 데이터
의 기본 단위 : byte (8bit)
기본 방법 :
int read( ) throws IOException
int read(byte[ ] buffer) throws IOException
int read(byte[ ] buffer,int offset,int length)throws IOException
void close( ) throws IOException
참고 :
read 메소드는 블로킹 메소드로
실제로 읽은 바이트 수를 반환하며 파일의 끝에 도달하면 -1
5
OutputStream을 반환 합니다.
OutputStream을 상속받은 클래스는 프로그램이
데이터 를 출력하는 데 사용됩니다 . 데이터 단위 : byte (8bit)
기본 방법 :
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
Flush는 캐시를 지우는 것, 즉 캐시 된 데이터를 파일에 기록합니다. Close는 일반 프로그램에서 파일을 닫는 것입니다. 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
라이터는
라이터의 클래스를 상속 출력 문자 사용
로부터 프로그램 . 데이터 유닛은 문자 (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