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

CODEDRAGON Development/Java

반응형

  

DataInputStream

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

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

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

 



 

 

 

DataInputStream의 생성자

생성자

설명

DataInputStream(InputStream in)

매개변수인 inputStream객체로 DataInputStream객체를 생성합니다.

 

 

 

DataInputStream의 주요 메소드

메소드 

설명 

boolean readBoolean() throws IOException

Stream으로부터 읽은 boolean을 반환

byte readByte() throws IOException

Stream으로부터 읽은 byte를 반환

char readChar() throws IOException

Stream으로부터 읽은 char를 반환

double readDouble throws IOException

Stream으로부터 double을 반환

float readFloat() throws IOException

Stream으로부터 float을 반환

long readLong() throws IOException

Stream으로부터 long을 반환

short readShort() throws IOException

Stream으로부터short를 반환

int readInt() throws IOException

Stream으로부터 int를 반환

void readFully(byte[] buf)

throws IOException

Stream으로부터 buf 크기만큼의 바이트를 읽어 buf[]에 저장

void readFully(byte[] buf, int off, int len)

throws IOException

Stream으로부터 len 길이만큼 바이트를 읽어 buf off 위치에 저장

String readUTF() throws IOException

UTF-8 인코딩 값을 얻어 문자열로 반환

static String readUTF(DataInput in)

throws IOException

DataInput의 수정된 UTF 인코딩 값을 얻어 문자열로 반환

int skipBytes(int n) throws IOException

n 만큼 바이트를 skip

 

 

Interface DataInput

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

 

 

Class DataInputStream

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

 

 

 

 

 

반응형