InputStream

A classe abstrata InputStream oferece a funcionalidade básica para a leitura de um byte ou de uma seqüência de bytes a partir de alguma fonte. Os principais métodos dessa classe incluem:

Method Summary
 int available()
          Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.
 void close()
          Closes this input stream and releases any system resources associated with the stream.
abstract  int read()
          Reads the next byte of data from the input stream.
 int read(byte[] b)
          Reads some number of bytes from the input stream and stores them into the buffer array b.
 int read(byte[] b, int off, int len)
          Reads up to len bytes of data from the input stream into an array of bytes.
 long skip(long n)
          Skips over and discards n bytes of data from this input stream.

Os métodos read(...) oferecem a funcionalidade básica de leitura de bytes. O valor de retorno para esses métodos é um inteiro, que pode ser o byte lido (para o caso do método sem argumentos) ou o número de bytes lidos (para os métodos que fazem a leitura para um arranjo de bytes). Em qualquer caso, um valor de retorno -1 indica que o final do arquivo foi atingido.

Além dos métodos indicados, esta classe tem métodos para lidar com a posição de leitura no arquivo (mark() e reset()), se essa funcionalidade for suportada (o que pode ser consultado pelo método markSupported()).


© Ivan Luiz Marques Ricarte
DCA/FEEC/UNICAMP

Last modified: Thu Jun 29 12:55:10 EST 2000