HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
🌚
[New] 우기팀
/
득윤
득윤
/
Java IO - 스트림 (Stream) / 버퍼 (Buffer) / 채널 (Channel) 기반의 I/O

Java IO - 스트림 (Stream) / 버퍼 (Buffer) / 채널 (Channel) 기반의 I/O

 

학습할 것 (필수)

  • 스트림 (Stream) / 버퍼 (Buffer) / 채널 (Channel) 기반의 I/O
  • InputStream과 OutputStream
  • Byte와 Character 스트림
  • 표준 스트림 (System.in, System.out, System.err)
  • 파일 읽고 쓰기

notion image
notion image
notion image

스트림, 버퍼, 채널

Stream 기반의 IO

notion image
  • 데이터가 들어온 순서대로 흘러가는 단방향의 통로
  • 자바의 모든 기본 I/O
  • 동기적, blocking 방식으로 동작
 

Buffer 기반의 IO

notion image
  • 임시로 데이터를 담아둘 수 있는 일종의 큐
  • Stream은 바이트 단위로 매번 read, write를 수행 하여 비효율적임
  • Buffer는 중간에서 입력을 모아서 한번에 출력하게 하여 더 효율적임
 

Channel 기반의 IO

notion image
  • 데이터가 흘러다니는 양방향의 통로
  • input/output 구분하지 않음
  • blocking/non-blocking 모두 지원
  • 기본적으로 buffer방식

 
많은 java.io 패키지의 클래스 중 InputStream과 OutputStream을 더 깊게 학습해보자.

InputStream

 
/** * This abstract class is the superclass of all classes representing * an input stream of bytes. * * Applications that need to define a subclass of InputStream * must always provide a method that returns the next byte of input. */
java.io.InputStream javadoc
 
public abstract class InputStream implements Closeable { private static final int DEFAULT_BUFFER_SIZE = 8192; }