FilterInputStream
FilterInputStream의 기능은 "다른 입력 스트림을 캡슐화하고 추가 기능을 제공하는 것"입니다. 일반적으로 사용되는 서브 클래스는 BufferedInputStream 및 DatainputStream입니다.
BufferedInputStream의 함수는 "입력 스트림에 대한 버퍼링 함수와 mark () 및 reset () 함수"를 제공하는 것입니다.
DatainputStream은 다른 입력 스트림을 장식하는 데 사용되며, "애플리케이션이 기본 입력 스트림에서 기본 입력 스트림에서 기본 Java 데이터 유형을 읽을 수 있습니다." 응용 프로그램은 DataOutputStream을 사용하여 DatainputStream에서 읽은 데이터를 작성할 수 있습니다.
FilterInputStream 소스 코드 (JDK1.7.40 기반) :
패키지 java.io; public class filterinputStream은 inputStream {Protected Volatile InputStream in; 보호 된 FilterInputStream (inputStream in) {this.in = in; } public int read ()가 IoException {return in.read (); } public int read (byte b [])는 ioexception {return read (b, 0, b.length); } public int read (byte b [], int off, int len)는 ioexception {return in.read (b, off, len); } public long skip (long n)은 ioexception {return in.skip (n); } public int availed ()는 ioexception {return in.available (); } public void close ()는 IoException {in.close (); } public synchronized void mark (int readlimit) {in.mark (readlimit); } public synchronized void reset ()는 ioexception {in.reset (); } public boolean marksupported () {return in.marksupported (); }} FilterOutputStream
FilterOutputStream의 기능은 "다른 출력 스트림을 캡슐화하고 추가 기능을 제공하는 것"입니다. 주로 BufferedOutputStream, DataOutputStream 및 PrintStream이 포함됩니다.
(01) BufferedOutputStream의 기능은 "출력 스트림에 대한 버퍼링 기능"을 제공하는 것입니다.
(02) DataOutputStream은 DataOutputStream 및 DataInputStream 입력 스트림을 사용하여 다른 출력 스트림을 장식하는 데 사용됩니다.
(03) PrintStream은 다른 출력 스트림을 장식하는 데 사용됩니다. 다른 출력 스트림에 기능을 추가하여 다양한 데이터 값 표현을 쉽게 인쇄 할 수 있습니다.
FilterOutputStream 소스 코드 (JDK1.7.40 기반) :
package java.io; public class FilterOutputStream은 outputStream {Protected OutputStream Out; public FilterOutputStream (outputStream out) {this.out = out; } public void write (int b)는 ioexception {out.write (b); } public void write (byte b [])는 ioexception {쓰기 (b, 0, b.length); } public void Writ for (int i = 0; i <len; i ++) {쓰기 (b [off+i]); }} public void flush ()는 ioexception {out.flush (); } public void close ()는 IoException {try {flush (); } catch (ioexception 무시) {} out.close (); }}