-
[TIL] 2022년 9월 15일 목요일카테고리 없음 2022. 9. 15. 23:20
1.3 바이트기반 스트림 - InputStream, OutputStream
스트림은 바이트 단위로 데이터를 전송한다. InputStream과 OutputStream은 입출력 대상에 따라 자식 클래스로 다음의 클래스가 있다. 책에는 크게 File(파일), ByteArray(메모리, byte배열), Piped(프로세스), Audio(오디오 장치)가 있는데 AudioInputStream은 패키지가 다르고 AudioOutputStream은 검색해봐도 안 나온다.
InputStream과 OutputStream의 추상메소드로 각각 read()와 write(int b)가 있다. 추상 메서드 칸을 보면 각각의 추상메서드와 오버로드된 두 개의 메소드가 있다.
// InputStream public abstract int read() throws IOException public int read(byte[] b) throws IOException public int read(byte[] b, int off, int len) throws IOException // OutputStream public abstract void write(int b) throws IOException public void write(byte[] b) throws IOException public void write(byte[] b, int off, int len) throws IOException
1.4 보조 스트림