DataOutputStream, DataOutputStream의 주요 생성자, DataOutputStream의 주요 메소드

CODEDRAGON Development/Java

반응형

 

 

DataOutputStream

·       DataOutputStream 클래스는 출력 스트림으로 부터 기본 자료형 데이터를 쓸 수 있는 각종 메서드와 문자를 쓸 수 있는 메서드를 정의 하고 있습니다.

·       DataOutputStream 클래스의 생성자는 한 개로 구성되어 있으며, 어떠한 예외 처리도 되어 있지 않습니다.

·       문자열도 바이너리 형태로 출력합니다.

 

 


 

 

DataOutputStream의 주요 생성자

생성자

설명

DataOutputStream(OutputStream out)

매개변수인  OutputStream 객체로 DataOutputStream 객체를 생성합니다.

 

 


 

DataOutputStream의 주요 메소드

메소드

설명 

void flush() throws IOException

버퍼의 내용를 출력하고 비우기

int size()

Stream에 출력된 바이트 크기를 반환

void write(int i) throws IOException

int i 값이 갖는 1바이트를 출력

void write(byte buf[], int index, int size)

throws IIOException

byte 배열 buf index 위치에서 size만큼 출력

void writeBoolean(boolean b) throws IOException

boolena 1바이트 값으로 출력

void writeByte(int i) throws IOException

int 4바이트 값으로 상위 바이트 먼저 출력

void writeBytes(String s) throws IOException

문자열을 바이트 순으로 출력

void writeChar(int i) throws IOException

char 2바이트 값으로 상위 바이트 먼저 출력

void writeChars(String s) throws IOException

String 문자열을 char형으로 출력

void writeDouble(double d) throws IOException

Double 클래스의 doubleToBits()를 사용하여 long으로 변환한 다음 long 값을 8바이트수량으로 상위바이트 먼저 출력

void writeFloat(float f) throws IOException

Float floatToBits()를 사용하여 변환한 다음 int 값을 4바이트 수량으로 상위 바이트 먼저 출력

void writeInt(int i) throws IOException

int의 상위 바이트 먼저 출력

void writeLong(long l) throws IOException

long 형의 인자값 출력

void writeShort(shrot s) throws IOException

short형의 인자값 출력

void writeUTF(String s) throws IOException

UTF-8 인코딩을 사용해서 문자열을 출력

 

 

Interface DataOutput

https://docs.oracle.com/javase/8/docs/api/java/io/DataOutput.html

 

 

 

Class DataOutputStream

https://docs.oracle.com/javase/8/docs/api/java/io/DataOutputStream.html

 

반응형