본문 바로가기
자바

DataOutputStream 클래스

by 복제비 2022. 3. 3.

DataOutputStream 클래스

 

DataOutputStream 클래스 개요


DataOutputStream 클래스는 자바의 기본 자료형 데이터를 바이트 스트림으로 출력하는 기능을 제공합니다.

 

DataOutputStream 클래스FilterOutputStream 클래스로부터 상속된 클래스입니다.

 

DataOutputStream 클래스DataOutput 인터페이스사용하는 클래스입니다.

 

DataOutputStream 클래스의 생성자


DataOutputStream(OutputStream outputStream)

 

DataOutput 인터페이스의 메서드들

 

◈ void write(int i) throws IOException

i 를 스트림으로 출력하는 메서드입니다.

 

void write(byte buffer[ ]) throws IOException

buffer 를 스트림으로 출력하는 메서드입니다.

 

void write(byte buffer[ ], int index, int size) throws IOException

buffer 의 index 위치부터 size 만큼의 바이트를 스트림으로 출력하는 메서드입니다.

 

void writeBoolean(boolean b) throws IOException

b 를 스트림으로 출력하는 메서드입니다.

 

void writeByte(int  i) throws IOException

i 의 하위 8비트를 스트림으로 출력하는 메서드입니다.

 

void writeBytes(String s) throws IOException

문자열 s 를 스트림으로 출력하는 메서드입니다.

 

void writeChar(int  i) throws  IOException

i 의 하위 16비트를 스트림으로 출력하는 메서드입니다.

 

void writeChars(String s) throws IOException

문자열 s 를 스트림으로 출력하는 메서드입니다.

 

void writeDouble(double d) throws IOException

d 를 스트림으로 출력하는 메서드입니다.

 

void writeFloat(float  f) throws IOException

f 를 스트림으로 출력하는 메서드입니다.

 

void writeInt(int  i) throws IOException

i 를 스트림으로 출력하는 메서드입니다.

 

void writeLong(long l) throws IOException

l 을 스트림으로 출력하는 메서드입니다.

 

void writeShort(short  s) throws IOException

s 를 스트림으로 출력하는 메서드입니다.

 

void writeUTF(String  s) throws IOException

s 를 스트림으로 출력하는 메서드입니다.

유니코드를 UTF-8 엔코딩을 이용하여 변환합니다.

 

DataOutputStream 클래스의 실습 프로그램

 

프로그램을 실행한 결과는 지정한 파일인 DataOutputStream.txt 파일에 기본 자료형 데이터를 바이트 스트림 방식으로 출력을 완료한 후에 콘솔출력 완료 문자열을 출력해 줍니다.

'자바' 카테고리의 다른 글

PrintStream 클래스  (0) 2022.03.16
DataInputStream 클래스  (0) 2022.03.04
BufferedInputStream 클래스  (0) 2022.03.02
BufferedOutputStream 클래스  (0) 2022.03.01
FilterInputStream 클래스  (0) 2022.02.28

댓글