바이트 채널
바이트 채널 (ByteChannel)
바이트를 읽고 쓰는 양방향 채널을 나타내는 인터페이스예요. ReadableByteChannel과 WritableByteChannel을 결합한 것입니다.
본문
ByteChannel은 바이트를 읽고 쓸 수 있는 양방향 채널을 나타내는 인터페이스예요.
public interface ByteChannel extends ReadableByteChannel, WritableByteChannel
이 인터페이스는 ReadableByteChannel(읽기)과 WritableByteChannel(쓰기)을 결합한 것으로, 새 메서드는 정의하지 않아요.
int read(ByteBuffer dst) throws IOException
int write(ByteBuffer src) throws IOException
read(ByteBuffer)— 버퍼로 바이트를 읽어요.write(ByteBuffer)— 버퍼의 바이트를 써요.
파일 채널, 소켓 채널, 시커블 바이트 채널 등이 이 인터페이스를 구현하며, Channel을 상속하므로 isOpen()과 close()도 사용할 수 있어요.