org.basex.io
Class BufferInput

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

public class BufferInput
extends Object

This class serves as a buffered wrapper for input streams.

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

Constructor Summary
BufferInput(byte[] buf)
          Empty constructor.
BufferInput(File file)
          Initializes the file reader.
BufferInput(File file, byte[] buf)
          Initializes the file reader.
BufferInput(InputStream is)
          Initializes the file reader.
BufferInput(InputStream is, byte[] b)
          Initializes the file reader.
BufferInput(String file)
          Initializes the file reader.
 
Method Summary
 void close()
          Closes the input stream.
 void encoding()
          Determines the file encoding.
 void encoding(String e)
          Sets a new encoding.
 long length()
          Length of input.
 void length(long l)
          Sets the input length.
 int read()
          Reads a single byte and returns it as integer.
static void read(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.
 String readString()
          Reads a string from the input stream.
 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(String file)
            throws IOException
Initializes the file reader.

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

BufferInput

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

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

BufferInput

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

Parameters:
is - input stream
Throws:
IOException - IO Exception

BufferInput

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

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

BufferInput

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

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

BufferInput

public BufferInput(byte[] buf)
Empty constructor.

Parameters:
buf - buffer
Method Detail

read

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

Parameters:
file - the file to be read
cont - byte array
Throws:
IOException - IO Exception

encoding

public final void encoding()
Determines the file encoding.


encoding

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

Parameters:
e - encoding
Throws:
IOException - IO Exception

read

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

Returns:
read byte
Throws:
IOException - I/O exception

readByte

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

Returns:
next byte
Throws:
IOException - I/O exception

readString

public String readString()
                  throws IOException
Reads a string from the input stream.

Returns:
string
Throws:
IOException - IO Exception

readChar

public final int readChar()
                   throws 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:
IOException - I/O exception

close

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

Throws:
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)
Sets the input length.

Parameters:
l - input length