java.io
Class DataInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.DataInputStream
All Implemented Interfaces:
DataInput

public class DataInputStream
extends InputStream
implements DataInput

바이트 정보를 읽어서 다른 타입의 정보로 변환할 수 있도록 만든 입력스트림 클래스.


Field Summary
protected  InputStream in
          실제 바이트 정보를 읽어올 입력 스트림.
 
Constructor Summary
DataInputStream(InputStream in)
          새로운 객체를 만든다.
 
Method Summary
 int available()
          입력 스트림에서 읽을 수 있는 정보량을 구한다.
 void close()
          입력 스트림을 닫는다.
 void mark(int readlimit)
          입력 스트림에 mark정보를 설정한다.
 boolean markSupported()
          입력 스트림이 mark기능을 지원하는지 여부를 구한다.
 int read()
          한 바이트를 읽는다.
 int read(byte[] b)
          바이트 배열로 읽어 들인다.
 int read(byte[] b, int off, int len)
          바이트 배열 일부분으로 읽어 들인다.
 boolean readBoolean()
          입력 스트림에서 한 바이트를 읽은 뒤 0이 아니면 true 0이면 false를 리턴한다.
 byte readByte()
          입력 스트림에서 한 바이트를 읽는다.
 char readChar()
          입력 스트림에서 char형 정보를 읽는다.
 double readDouble()
           
 float readFloat()
           
 void readFully(byte[] b)
          바이트 배열로 읽어 들인다. read와 다른 점은 바이트 배열이 다 차기 전에 입력받을 정보가 없어지면 EOFException을 발생한다는 점이다.
 void readFully(byte[] b, int off, int len)
          바이트 배열 일부분으로 읽어 들인다. read와 다른 점은 원하는 양만큼 읽기 전에 입력받을 정보가 없어지면 EOFException을 발생한다는 점이다.
 int readInt()
          입력 스트림에서 정수형 정보를 읽는다.
 long readLong()
          입력 스트림에서 Long형 정보를 읽는다.
 short readShort()
          입력 스트림에서 두 바이트를 읽는다.
 int readUnsignedByte()
          입력 스트림에서 한 바이트를 읽고 unsigned 바이트로 처리해 정수형 정보로 변환 후 리턴한다.
 int readUnsignedShort()
          입력 스트림에서 두 바이트를 읽고 unsigned short로 처리해 정수형 정보로 변환 후 리턴한다.
 String readUTF()
          입력 스트림에서 UTF형식 정보를 읽어 문자열을 만들어 리턴한다.
static String readUTF(DataInput in)
          특정 입력 스트림에서 UTF형식 정보를 읽어 문자열을 만들어 리턴한다.
 void reset()
          입력 스트림의 읽는 위치를 mark정보에 설정된 위치로 변경한다.
 long skip(long n)
          입력 스트림에서 정보를 읽지 않고 건너뛴다.
 int skipBytes(int n)
          입력 스트림에서 정보를 읽지 않고 건너뛴다.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

protected InputStream in
실제 바이트 정보를 읽어올 입력 스트림.
Constructor Detail

DataInputStream

public DataInputStream(InputStream in)
새로운 객체를 만든다.
Parameters:
in - 실제 바이트 정보를 읽어올 입력 스트림.
Method Detail

read

public int read()
         throws IOException
한 바이트를 읽는다.
Overrides:
read in class InputStream
Returns:
읽은 바이트 정보.
Throws:
IOException -  

read

public final int read(byte[] b)
               throws IOException
바이트 배열로 읽어 들인다.
Overrides:
read in class InputStream
Parameters:
b - 읽은 정보가 저장될 바이트 배열.
Returns:
실제 읽은 바이트 수, 읽은 바이트가 없으면 -1.
Throws:
IOException -  

read

public final int read(byte[] b,
                      int off,
                      int len)
               throws IOException
바이트 배열 일부분으로 읽어 들인다.
Overrides:
read in class InputStream
Parameters:
b - 읽은 정보가 저장될 바이트 배열.
off - b에서 저장을 시작할 위치.
len - 읽을 바이트 수.
Returns:
실제 읽은 바이트 수, 읽은 바이트가 없으면 -1.
Throws:
IOException -  

readFully

public final void readFully(byte[] b)
                     throws IOException
바이트 배열로 읽어 들인다. read와 다른 점은 바이트 배열이 다 차기 전에 입력받을 정보가 없어지면 EOFException을 발생한다는 점이다.
Specified by:
readFully in interface DataInput
Parameters:
b - 읽은 정보가 저장될 바이트 배열.
Throws:
IOException -  
EOFException - 읽을 량을 채우지 못할 ‹š 발생.

readFully

public final void readFully(byte[] b,
                            int off,
                            int len)
                     throws IOException
바이트 배열 일부분으로 읽어 들인다. read와 다른 점은 원하는 양만큼 읽기 전에 입력받을 정보가 없어지면 EOFException을 발생한다는 점이다.
Specified by:
readFully in interface DataInput
Parameters:
b - 읽은 정보가 저장될 바이트 배열.
off - b에서 저장을 시작할 위치.
len - 읽을 바이트 수.
Throws:
EOFException - 읽을 량을 채우지 못할 ‹š 발생.
IOException -  

skipBytes

public final int skipBytes(int n)
                    throws IOException
입력 스트림에서 정보를 읽지 않고 건너뛴다.
Specified by:
skipBytes in interface DataInput
Parameters:
n - 건너 뛸 갯수.
Returns:
실제로 건너 뛴 갯수.
Throws:
IOException -  

mark

public void mark(int readlimit)
입력 스트림에 mark정보를 설정한다.
Overrides:
mark in class InputStream

reset

public void reset()
           throws IOException
입력 스트림의 읽는 위치를 mark정보에 설정된 위치로 변경한다.
Overrides:
reset in class InputStream
Throws:
IOException -  

markSupported

public boolean markSupported()
입력 스트림이 mark기능을 지원하는지 여부를 구한다.
Overrides:
markSupported in class InputStream
Returns:
지원하면 true 아니면 false.

readBoolean

public final boolean readBoolean()
                          throws IOException
입력 스트림에서 한 바이트를 읽은 뒤 0이 아니면 true 0이면 false를 리턴한다.
Specified by:
readBoolean in interface DataInput
Returns:
boolean 값.
Throws:
IOException -  

readByte

public final byte readByte()
                    throws IOException
입력 스트림에서 한 바이트를 읽는다.
Specified by:
readByte in interface DataInput
Returns:
읽은 한 signed 바이트.
Throws:
IOException -  

readUnsignedByte

public final int readUnsignedByte()
                           throws IOException
입력 스트림에서 한 바이트를 읽고 unsigned 바이트로 처리해 정수형 정보로 변환 후 리턴한다.
Specified by:
readUnsignedByte in interface DataInput
Returns:
읽은 한 unsigned 바이트가 변환된 정수값.
Throws:
IOException -  

readChar

public final char readChar()
                    throws IOException
입력 스트림에서 char형 정보를 읽는다.
Specified by:
readChar in interface DataInput
Returns:
읽은 char형 정보.
Throws:
IOException -  
EOFException - 2바이트를 읽을 수 없을 때 발생.

readShort

public final short readShort()
                      throws IOException
입력 스트림에서 두 바이트를 읽는다.
Specified by:
readShort in interface DataInput
Returns:
읽은 signed short형 정보.
Throws:
IOException -  
EOFException - 2바이트를 읽을 수 없을 때 발생.

readUnsignedShort

public final int readUnsignedShort()
                            throws IOException
입력 스트림에서 두 바이트를 읽고 unsigned short로 처리해 정수형 정보로 변환 후 리턴한다.
Specified by:
readUnsignedShort in interface DataInput
Returns:
읽은 두 unsigned short가 변환된 정수값.
Throws:
IOException -  
EOFException - 2바이트를 읽을 수 없을 때 발생.

readInt

public final int readInt()
                  throws IOException
입력 스트림에서 정수형 정보를 읽는다.
Specified by:
readInt in interface DataInput
Returns:
읽은 정수형 정보.
Throws:
IOException -  
EOFException - 4바이트를 읽을 수 없을 때 발생.

readLong

public final long readLong()
                    throws IOException
입력 스트림에서 Long형 정보를 읽는다.
Specified by:
readLong in interface DataInput
Returns:
읽은 Long형 정보.
Throws:
IOException -  
EOFException - 8바이트를 읽을 수 없을 때 발생.

readFloat

public final float readFloat()
                      throws IOException
Specified by:
readFloat in interface DataInput

readDouble

public final double readDouble()
                        throws IOException
Specified by:
readDouble in interface DataInput

readUTF

public final String readUTF()
                     throws IOException
입력 스트림에서 UTF형식 정보를 읽어 문자열을 만들어 리턴한다.
Specified by:
readUTF in interface DataInput
Returns:
문자열.
Throws:
IOException -  

readUTF

public static final String readUTF(DataInput in)
                            throws IOException
특정 입력 스트림에서 UTF형식 정보를 읽어 문자열을 만들어 리턴한다.
Parameters:
in - UTF형식 정보를 읽어들일 입력 스트림.
Returns:
문자열.
Throws:
IOException -  

available

public int available()
              throws IOException
입력 스트림에서 읽을 수 있는 정보량을 구한다.
Overrides:
taInput.html#readUTF()">readUTF in interface DataInput
Returns:
臾몄ž