Java 바이트 스트림 DataInputStream/DataOutputStream
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 인코딩 값을 얻어 문자열로 반환한다. |
| static String readUTF(DataInput in) throws IOException | DataInput의 수정된 UTF 인코딩 값을 얻어 문자열로 반환한다. |
| int skipBytes(int n) throws IOException | n 만큼 바이트를 skip 한다. |
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 IOException | 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 인코딩을 사용해서 문자열을 출력한다. |