Interpreter.Utils
Class InputBuffer

java.lang.Object
  |
  +--java.io.Reader
        |
        +--java.io.BufferedReader
              |
              +--Interpreter.Utils.InputBuffer

public class InputBuffer
extends java.io.BufferedReader

Buffer di input che estende le funzionalitą del BufferedReader. Aggiunge i metodi available() e skip(int n) che non sono presenti nel BufferedReader.


Fields inherited from class java.io.Reader
lock
 
Constructor Summary
InputBuffer(java.io.InputStream in)
          Costruisce un nuovo InputBuffer.
 
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.
 java.lang.String ReadLine()
          Read a line of text.
 long skip(int n)
          Skips over and discards n bytes of data from this input stream.
 
Methods inherited from class java.io.BufferedReader
close, mark, markSupported, read, read, readLine, ready, reset, skip
 
Methods inherited from class java.io.Reader
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputBuffer

public InputBuffer(java.io.InputStream in)
Costruisce un nuovo InputBuffer.
Parameters:
in - lo stream che deve essere bufferizzato.
Method Detail

ReadLine

public java.lang.String ReadLine()
                          throws InterpreterException
Read a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed. return A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached
Throws:
InterpreterException - If an I/O error occurs.

available

public int available()
              throws InterpreterException
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.
The next caller might be the same thread or or another thread.
Returns:
the number of bytes that can be read from this input stream without blocking.
Throws:
InterpreterException - If an I/O error occurs.

skip

public long skip(int n)
          throws InterpreterException
Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, no bytes are skipped.

The skip method of InputStream creates a byte array and then repeatedly reads into it until n bytes have been read or the end of the stream has been reached. Subclasses are encouraged to provide a more efficient implementation of this method.

Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
InterpreterException - If an I/O error occurs.


Codice realizzato da Francesco Geri & Marco Tamanti