amber.type
Class AmberInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.FilterInputStream
              |
              +--java.io.DataInputStream
                    |
                    +--amber.type.AmberInputStream
All Implemented Interfaces:
java.io.DataInput

public class AmberInputStream
extends java.io.DataInputStream

An extension to the standard DataInputStream. This object allows the streaming of strings > 32k characters. It also handles null strings.

Version:
1.0.0
Author:
Dr. David J. Knowles
See Also:
DataInputStream

Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
AmberInputStream(java.io.InputStream in)
          Creates a new input stream which reads data from the defined input stream.
 
Method Summary
 java.lang.String readLongUTF()
          Reads in a string that has been encoded using an extended form of that used by the readUTF function.
static java.lang.String readLongUTF(java.io.DataInput in)
          Reads in a string that has been encoded using an extended form of that used by the readUTF function.
 
Methods inherited from class java.io.DataInputStream
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AmberInputStream

public AmberInputStream(java.io.InputStream in)
Creates a new input stream which reads data from the defined input stream.
Parameters:
in. - The input stream to use.
Method Detail

readLongUTF

public final java.lang.String readLongUTF()
                                   throws java.io.IOException
Reads in a string that has been encoded using an extended form of that used by the readUTF function.

This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.

Returns:
a String which is the decoded input.
Throws:
java.io.EOFException - if this input stream reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.

readLongUTF

public static final java.lang.String readLongUTF(java.io.DataInput in)
                                          throws java.io.IOException
Reads in a string that has been encoded using an extended form of that used by the readUTF function. This function is a modified version of the readUTF function which has a 65536 byte limit.

This function differs in two ways:
First, the length is encoded using 4 bytes rather than 2. This allows long strings to be encoded.
Second, the encoding of the string is preceeded by a type byte. This allows the stream to encode null strings in a meaningful way. For this reason THIS FUNCTION CAN RETURN A NULL FOR THE STRING.

This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.

Parameters:
in - The data input stream to read the data from.
Returns:
a Unicode string.
Throws:
java.io.EOFException - if the input stream reaches the end before all the bytes.
java.io.IOException - if an I/O error occurs.
UTFDataFormatException - if the bytes do not represent a valid UTF-8 encoding of a Unicode string.


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.