org.PingOO.DLAI.PPM.io
Class ExtendedDataInputStream

java.lang.Object
  |
  +--org.PingOO.DLAI.PPM.io.ExtendedDataInputStream

public final class ExtendedDataInputStream
extends java.lang.Object

Reads datas on an InputStream. The class can get char, chars array, bytes, bytes array or String lines from a stream.

Since:
PingOO 2.0
Version:
2.0
Author:
Fabrice Bouyé (bouye@cur-archamps.fr)

Field Summary
private  java.io.DataInputStream dataInputStream
          The DataInputStream to which is delegated some parts of the job.
private  java.io.InputStream inputStream
          The InputStream associated with this reader.
 
Constructor Summary
ExtendedDataInputStream(java.io.InputStream in)
          Creates an ExtendedDataInputStream intended to retreive datas from an InputStream.
 
Method Summary
 void close()
           
 int read(byte[] byteBuffer)
          Reads a bytes array from the InputStream
 int read(byte[] byteBuffer, int off, int length)
          Reads a bytes array from the InputStream
 byte readByte()
          Reads one byte on the underlying InputStream.
 char readChar()
          Reads a character on the underlying InputStream.
 int readInt()
          Reads one int on the underlying InputStream.
 java.lang.String readLine()
          Reads a line from the stream and return it.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

inputStream

private java.io.InputStream inputStream
The InputStream associated with this reader.

dataInputStream

private java.io.DataInputStream dataInputStream
The DataInputStream to which is delegated some parts of the job.
Constructor Detail

ExtendedDataInputStream

public ExtendedDataInputStream(java.io.InputStream in)
                        throws java.lang.NullPointerException
Creates an ExtendedDataInputStream intended to retreive datas from an InputStream.
Parameters:
in - The underlying stream need to get datas.
Throws:
java.lang.NullPointerException - If the InputStream does not exist.
Method Detail

read

public final int read(byte[] byteBuffer)
               throws java.io.IOException
Reads a bytes array from the InputStream
Parameters:
byteBuffer - The buffer into which the data is read.
Returns:
The total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException - If an I/O error occurs.

read

public final int read(byte[] byteBuffer,
                      int off,
                      int length)
               throws java.io.IOException
Reads a bytes array from the InputStream
Parameters:
byteBuffer - The buffer into which the data is read.
off - The start offset of the data.
lenght - The maximum number of bytes read.
Returns:
The total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException - If an I/O error occurs.

readByte

public final byte readByte()
                    throws java.io.IOException
Reads one byte on the underlying InputStream.
Returns:
One byte from on the stream.
Throws:
java.io.IOException - If an I/O error occurs.

readInt

public final int readInt()
                  throws java.io.IOException
Reads one int on the underlying InputStream.
Returns:
One int from on the stream.
Throws:
java.io.IOException - If an I/O error occurs.

readChar

public final char readChar()
                    throws java.io.IOException
Reads a character on the underlying InputStream.
Returns:
One character from on the stream.
Throws:
java.io.IOException - If an I/O error occurs.

readLine

public final java.lang.String readLine()
                                throws java.io.IOException
Reads a line from the stream and return it. A line is considered to be terminated when an line feed ('\n') or a return carrier ('\r') is encountered.
Returns:
A String containing the contents of the line, not including any line-termination characters.
Throws:
java.io.IOException - If an I/O error occurs.

close

public final void close()
                 throws java.io.IOException