org.basex.io
Class BufferInput

java.lang.Object
  extended by org.basex.io.BufferInput
Direct Known Subclasses:
CachedInput, DataInput

public class BufferInput
extends java.lang.Object

This class serves as a buffered wrapper for input streams.

Author:
Workgroup DBIS, University of Konstanz 2005-08, ISC License, Christian Gruen

Constructor Summary
BufferInput(byte[] buf)
          Empty constructor.
BufferInput(java.io.File file)
          Initializes the file reader.
BufferInput(java.io.File file, byte[] buf)
          Initializes the file reader.
BufferInput(java.io.InputStream is)
          Initializes the file reader.
BufferInput(java.io.InputStream is, byte[] b)
          Initializes the file reader.
BufferInput(java.lang.String file)
          Initializes the file reader.
BufferInput(java.lang.String file, byte[] buf)
          Initializes the file reader.
 
Method Summary
 void close()
          Closes the input stream.
 void encoding()
          Determines the file encoding.
 void encoding(java.lang.String e)
          Sets a new encoding.
 long length()
          Length of input.
 void length(long l)
          Set input length.
 int read()
          Reads a single byte and returns it as integer.
static int read(java.io.File file, byte[] cont)
          Fills the specified array with the beginning of the specified file.
 byte readByte()
          Returns the next byte or 0 if all bytes have been read.
 int readChar()
          Returns the next character, 0 if all bytes have been read or a negative character value -1 if the read byte is invalid.
 int size()
          Number of read bytes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferInput

public BufferInput(java.lang.String file)
            throws java.io.IOException
Initializes the file reader.

Parameters:
file - the file to be read
Throws:
java.io.IOException - IO Exception

BufferInput

public BufferInput(java.io.File file)
            throws java.io.IOException
Initializes the file reader.

Parameters:
file - the file to be read
Throws:
java.io.IOException - IO Exception

BufferInput

public BufferInput(java.io.InputStream is)
            throws java.io.IOException
Initializes the file reader.

Parameters:
is - input stream
Throws:
java.io.IOException - IO Exception

BufferInput

public BufferInput(java.lang.String file,
                   byte[] buf)
            throws java.io.IOException
Initializes the file reader.

Parameters:
file - the file to be read
buf - input buffer
Throws:
java.io.IOException - IO Exception

BufferInput

public BufferInput(java.io.File file,
                   byte[] buf)
            throws java.io.IOException
Initializes the file reader.

Parameters:
file - the file to be read
buf - input buffer
Throws:
java.io.IOException - IO Exception

BufferInput

public BufferInput(java.io.InputStream is,
                   byte[] b)
            throws java.io.IOException
Initializes the file reader.

Parameters:
is - input stream
b - input buffer
Throws:
java.io.IOException - IO Exception

BufferInput

public BufferInput(byte[] buf)
Empty constructor.

Parameters:
buf - buffer
Method Detail

read

public static int read(java.io.File file,
                       byte[] cont)
                throws java.io.IOException
Fills the specified array with the beginning of the specified file.

Parameters:
file - the file to be read
cont - byte array
Returns:
number of read bytes
Throws:
java.io.IOException - IO Exception

encoding

public final void encoding()
Determines the file encoding.


encoding

public final void encoding(java.lang.String e)
                    throws java.io.IOException
Sets a new encoding.

Parameters:
e - encoding
Throws:
java.io.IOException - IO Exception

read

public final int read()
               throws java.io.IOException
Reads a single byte and returns it as integer.

Returns:
read byte
Throws:
java.io.IOException - I/O exception

readByte

public byte readByte()
              throws java.io.IOException
Returns the next byte or 0 if all bytes have been read.

Returns:
next byte
Throws:
java.io.IOException - I/O exception

readChar

public final int readChar()
                   throws java.io.IOException
Returns the next character, 0 if all bytes have been read or a negative character value -1 if the read byte is invalid.

Returns:
next character
Throws:
java.io.IOException - I/O exception

close

public final void close()
                 throws java.io.IOException
Closes the input stream.

Throws:
java.io.IOException - IO Exception

size

public final int size()
Number of read bytes.

Returns:
read bytes

length

public final long length()
Length of input.

Returns:
read bytes

length

public final void length(long l)
Set input length.

Parameters:
l - input length