org.apache.derby.iapi.services.io
Class InputStreamUtil

java.lang.Object
  extended byorg.apache.derby.iapi.services.io.InputStreamUtil

public final class InputStreamUtil
extends java.lang.Object

Utility methods for InputStream that are stand-ins for a small subset of DataInput methods. This avoids pushing a DataInputStream just to get this functionality.


Constructor Summary
InputStreamUtil()
           
 
Method Summary
static void readFully(java.io.InputStream in, byte[] b, int offset, int len)
          Read a number of bytes into an array.
static int readLoop(java.io.InputStream in, byte[] b, int offset, int len)
          Read a number of bytes into an array.
static int readUnsignedByte(java.io.InputStream in)
          Read an unsigned byte from an InputStream, throwing an EOFException if the end of the input is reached.
static long skipBytes(java.io.InputStream in, long n)
          Skip a number of bytes in the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputStreamUtil

public InputStreamUtil()
Method Detail

readUnsignedByte

public static int readUnsignedByte(java.io.InputStream in)
                            throws java.io.IOException
Read an unsigned byte from an InputStream, throwing an EOFException if the end of the input is reached.

Throws:
java.io.IOException - if an I/O error occurs.
java.io.EOFException - if the end of the stream is reached
See Also:
DataInput.readUnsignedByte()

readFully

public static void readFully(java.io.InputStream in,
                             byte[] b,
                             int offset,
                             int len)
                      throws java.io.IOException
Read a number of bytes into an array.

Throws:
java.io.IOException - if an I/O error occurs.
java.io.EOFException - if the end of the stream is reached
See Also:
DataInput.readFully(byte[])

readLoop

public static int readLoop(java.io.InputStream in,
                           byte[] b,
                           int offset,
                           int len)
                    throws java.io.IOException
Read a number of bytes into an array. Keep reading in a loop until len bytes are read or EOF is reached or an exception is thrown. Return the number of bytes read. (InputStream.read(byte[],int,int) does not guarantee to read len bytes even if it can do so without reaching EOF or raising an exception.)

Throws:
java.io.IOException - if an I/O error occurs.

skipBytes

public static long skipBytes(java.io.InputStream in,
                             long n)
                      throws java.io.IOException
Skip a number of bytes in the stream. Note that this version takes and returns a long instead of the int used by skipBytes.

Throws:
java.io.IOException - if an I/O error occurs.
java.io.EOFException - if the end of the stream is reached
See Also:
DataInput.skipBytes(int)


Apache Derby V10.0 Engine Documentation - Copyright © 1997,2004 The Apache Software Foundation or its licensors, as applicable.