DataInput

A interface DataInput é implementada pelas classes DataInputStream e RandomAccessFile. Os métodos especificados nesta interface possibilitam a interpretação de uma seqüência de bytes como um tipo primitivo da linguagem Java. Adicionalmente, é também possível interpretar a seqüência de bytes como um objeto String.

Em geral, métodos dessa interface geram uma exceção EOFException se for solicitada a leitura além do final do arquivo. Em outras situações de erro de leitura, a exceção IOException é gerada.

A documentação da API Java especifica os seguintes métodos para essa interface:

Method Summary
 boolean readBoolean()
          Reads one input byte and returns true if that byte is nonzero, false if that byte is zero.
 byte readByte()
          Reads and returns one input byte.
 char readChar()
          Reads an input char and returns the char value.
 double readDouble()
          Reads eight input bytes and returns a double value.
 float readFloat()
          Reads four input bytes and returns a float value.
 void readFully(byte[] b)
          Reads some bytes from an input stream and stores them into the buffer array b.
 void readFully(byte[] b, int off, int len)
          Reads len bytes from an input stream.
 int readInt()
          Reads four input bytes and returns an int value.
 String readLine()
          Reads the next line of text from the input stream.
 long readLong()
          Reads eight input bytes and returns a long value.
 short readShort()
          Reads two input bytes and returns a short value.
 int readUnsignedByte()
          Reads one input byte, zero-extends it to type int, and returns the result, which is therefore in the range 0 through 255.
 int readUnsignedShort()
          Reads two input bytes and returns an int value in the range 0 through 65535.
 String readUTF()
          Reads in a string that has been encoded using a modified UTF-8 format.
 int skipBytes(int n)
          Makes an attempt to skip over n bytes of data from the input stream, discarding the skipped bytes.


© Ivan Luiz Marques Ricarte
DCA/FEEC/UNICAMP

Last modified: Wed Nov 17 14:08:11 EDT 1999