Make your own free website on Tripod.com

appendix I

java.io Package Reference


CONTENTS

The java.io package provides classes with support for reading and writing data to and from different input and output devices, including files, strings, and other data sources. The I/O package includes classes for inputting streams of data, outputting streams of data, working with files, and tokenizing streams of data.

DataInput

This interface describes an input stream that can read input data in a platform-independent manner.

readBoolean

public abstract boolean readBoolean() throws IOException
This method reads a boolean value (byte) from the input stream. A value of 0 is interpreted as false, while all other values are interpreted as true.
Returns: The boolean value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readByte

public abstract byte readByte() throws IOException
This method reads a signed byte (8-bit) value from the input stream.
Returns: The byte value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readChar

public abstract char readChar() throws IOException
This method reads a Unicode character (16-bit) value from the input stream.
Returns: The Unicode character value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readDouble

public abstract double readDouble() throws IOException
This method reads a double (64-bit) value from the input stream.
Returns: The double value read.
Throws: EOFException if the end of the stream is reached before the value is read.
Throws: IOException if an I/O error occurs.

readFloat

public abstract float readFloat() throws IOException
This method reads a float (32-bit) value from the input stream.
Returns: The float value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readFully

public abstract void readFully(byte b[]) throws IOException
This method reads up to b.length bytes from the input stream into the byte array b, blocking until all bytes are read.
Parameters: b-the byte array into which the data is read.
Throws: EOFException if the end of the stream is reached before the specified number of bytes is read.
Throws: IOException if an I/O error occurs.

readFully

public abstract void readFully(byte b[], int off, int len) throws IOException
This method reads up to len bytes from the input stream into the byte array b beginning off bytes into the array, blocking until all bytes are read.
Parameters:
b-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Throws: EOFException if the end of the stream is reached before the specified number of bytes is read.
Throws: IOException if an I/O error occurs.

readInt

public abstract int readInt() throws IOException
This method reads an integer (32-bit) value from the input stream.
Returns: The integer value read.
Throws: EOFException if the end of the stream is reached before the value is read.
Throws: IOException if an I/O error occurs.

readLine

public abstract String readLine() throws IOException
This method reads a line of text from the input stream.
Returns: A string containing the line of text read.
Throws: EOFException if the end of the stream is reached before the line of text is read.
Throws: IOException if an I/O error occurs.

readLong

public abstract long readLong() throws IOException
This method reads a long (64-bit) value from the input stream.
Returns: The long value read.
Throws: EOFException if the end of the stream is reached before the value is read.
Throws: IOException if an I/O error occurs.

readShort

public abstract short readShort() throws IOException
This method reads a short (16-bit) value from the input stream.
Returns: The short value read.
Throws: EOFException if the end of the stream is reached before the value is read.
Throws: IOException if an I/O error occurs.

readUnsignedByte

public abstract int readUnsignedByte() throws IOException
This method reads an unsigned byte (8-bit) value from the input stream.
Returns: The unsigned byte value read.
Throws: EOFException if the end of the stream is reached before the value is read.
Throws: IOException if an I/O error occurs.

readUnsignedShort

public abstract int readUnsignedShort() throws IOException
This method reads an unsigned short (16-bit) value from the input stream.
Returns: The short value read.
Throws: EOFException if the end of the stream is reached before the value is read.
Throws: IOException if an I/O error occurs.

readUTF

public abstract String readUTF() throws IOException
This method reads a string that has been encoded using a modified UTF-8 format from the input stream.
Returns: The string read.
Throws: EOFException if the end of the stream is reached before the string is read.
Throws: UTFDataFormatException if the bytes read do not represent a valid UTF-8 encoding of a string.
Throws: IOException if an I/O error occurs.

skipBytes

public abstract int skipBytes(int n) throws IOException
This method skips n bytes of data in the input stream, blocking until all bytes are skipped.
Parameters: n-the number of bytes to skip.
Returns: The actual number of bytes skipped.
Throws: EOFException if the end of the stream is reached before skipping the specified number of bytes.
Throws: IOException if an I/O error occurs.

DataOutput

This interface describes an output stream that can write output data in a platform-independent manner.

write

public abstract void write(byte b[]) throws IOException
This method writes b.length bytes to the output stream from the byte array b, blocking until all bytes are written.
Parameters: b-the byte array from which the data is written.
Throws: IOException if an I/O error occurs.

write

public abstract void write(byte b[], int off, int len) throws IOException
This method writes len bytes to the output stream from the byte array b beginning off bytes into the array, blocking until all bytes are written.
Parameters:
b-the byte array from which the data is written.
off-the starting offset into the array for the data to be read from.
len-the number of bytes to write.
Throws: IOException if an I/O error occurs.

write

public abstract void write(int b) throws IOException
This method writes a byte value to the output stream, blocking until the byte is written.
Parameters: b-the byte value to be written.
Throws: IOException if an I/O error occurs.

writeBoolean

public abstract void writeBoolean(boolean v) throws IOException
This method writes a boolean value to the output stream. The boolean value true is written as the byte value 1, whereas false is written as the byte value 0.
Parameters: v-the boolean value to be written.
Throws: IOException if an I/O error occurs.

writeByte

public abstract void writeByte(int v) throws IOException
This method writes a byte (8-bit) value to the output stream.
Parameters: v-the byte value to be written.
Throws: IOException if an I/O error occurs.

writeBytes

public abstract void writeBytes(String s) throws IOException
This method writes a string to the output stream as a sequence of bytes.
Parameters: s-the string to be written as bytes.
Throws: IOException if an I/O error occurs.

writeChar

public abstract void writeChar(int v) throws IOException
This method writes a character (16-bit) value to the output stream.
Parameters: v-the character value to be written.
Throws: IOException if an I/O error occurs.

writeChars

public abstract void writeChars(String s) throws IOException
This method writes a string to the output stream as a sequence of characters.
Parameters: s-the string to be written as characters.
Throws: IOException if an I/O error occurs.

writeDouble

public abstract void writeDouble(double v) throws IOException
This method writes a double (64-bit) value to the output stream.
Parameters: v-the double value to be written.
Throws: IOException if an I/O error occurs.

writeFloat

public abstract void writeFloat(float v) throws IOException
This method writes a float (32-bit) value to the output stream.
Parameters: v-the float value to be written.
Throws: IOException if an I/O error occurs.

writeInt

public abstract void writeInt(int v) throws IOException
This method writes an integer (32-bit) value to the output stream.
Parameters: v-the integer value to be written.
Throws: IOException if an I/O error occurs.

writeLong

public abstract void writeLong(long v) throws IOException
This method writes a long (64-bit) value to the output stream.
Parameters: v-the long value to be written.
Throws: IOException if an I/O error occurs.

writeShort

public abstract void writeShort(int v) throws IOException
This method writes a short (16-bit) value to the output stream.
Parameters: v-the short value to be written.
Throws: IOException if an I/O error occurs.

writeUTF

public abstract void writeUTF(String str) throws IOException
This method encodes a string using a modified UTF-8 format and writes it to the output stream.
Parameters: str-the string to be written.
Throws: IOException if an I/O error occurs.

FilenameFilter

This interface describes a filename filter used to filter directory listings. Filename filters are used by the list method defined in the File class, as well as the awt's FileDialog component.

accept

public abstract boolean accept(File dir, String name)
This method determines whether a file should be included in a directory listing.
Parameters:
dir-the directory in which the file is located.
name-the filename.
Returns: true if the file should be included in the directory list; false otherwise.

BufferedInputstream

Extends: FilterInputStream

This class implements a buffered input stream, which allows you to read data from a stream without causing a call to the underlying system for each byte read. This is accomplished by reading blocks of data into a buffer, where the data is readily accessible, independent of the underlying stream. Subsequent reads are much faster since they read from the buffer rather than the underlying input stream.

Member Variables

protected byte buf[]

This is the buffer where data is stored.

protected int count

This is the number of bytes of data currently in the buffer.

protected int marklimit

This is the maximum number of bytes that can be read before the marked position (markpos) is invalidated.

protected int markpos

This is the position in the buffer of the current mark, which provides a means to return to a particular location in the buffer via the mark and reset methods. The mark position is set to -1 if there is no current mark.

protected int pos

This is the current read position in the buffer.

BufferedInputStream Constructor

public BufferedInputStream(InputStream in)
This constructor creates a new buffered input stream with a default buffer size of 512 bytes to read data from the in input stream.
Parameters: in-the input stream to read data from.

BufferedInputStream Constructor

public BufferedInputStream(InputStream in, int size)
This constructor creates a new buffered input stream with a buffer size of size bytes to read data from the in input stream.
Parameters: in-the input stream to read data from.
Parameters: size-the buffer size.

availableBufferedInputStream

public int available() throws IOException
This method determines the number of bytes that can be read from the input stream without blocking. This value is calculated by adding the number of free bytes in the buffer and the number of bytes available in the input stream.
Returns: The number of available bytes.
Throws: IOException if an I/O error occurs.

markBufferedInputStream

public void mark(int readlimit)
This method marks the current read position in the input stream. The reset method can be used to reset the read position to this mark; subsequent reads will read data beginning at the mark position. The mark position is invalidated after readlimit bytes have been read.
Parameters: readlimit-the maximum number of bytes that can be read before the mark position becomes invalid.

markSupportedBufferedInputStream

public boolean markSupported()
This method determines if the input stream supports the mark and reset methods.
Returns: true if the mark and reset methods are supported; false otherwise.

readBufferedInputStream

public int read() throws IOException
This method reads a byte value from the buffered input stream, blocking until the byte is read.
Returns: An integer representing the byte value read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

readBufferedInputStream

public int read(byte b[], int off, int len) throws IOException
This method reads up to len bytes from the buffered input stream into the byte array b beginning off bytes into the array, blocking until all bytes are read.
Parameters:
b-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

resetBufferedInputStream

public void reset() throws IOException
This method resets the read position in the input stream to the current mark position, as set by the mark method.
Throws: IOException if the stream has not been marked or if the mark is invalid.

skipBufferedInputStream

public long skip(long n) throws IOException
This method skips n bytes of data in the input stream.
Parameters: n-the number of bytes to skip.
Returns: The actual number of bytes skipped.
Throws: IOException if an I/O error occurs.

BufferedOutputStream

Extends: FilterOutputStream

This class implements a buffered output stream, which allows you to write data to a stream without causing a call to the underlying system for each byte written. This is accomplished by writing blocks of data into a buffer rather than directly to the underlying output stream. The buffer is then written to the underlying output stream when the buffer fills up or is flushed, or the stream is closed.

Member Variables

protected byte buf[]

This is the buffer where data is stored.

protected int count

This is the number of bytes of data currently in the buffer.

BufferedOutputStream Constructor

public BufferedOutputStream(OutputStream out)
This constructor creates a new buffered output stream with a default buffer size of 512 bytes to write data to the out output stream.
Parameters: out-the output stream to write data to.

BufferedOutputStream Constructor

public BufferedOutputStream(OutputStream out, int size)
This constructor creates a new buffered output stream with a buffer size of size bytes to write data to the out output stream.
Parameters:
out-the output stream to write data to.
size-the buffer size.

flushBufferedOutputStream

public void flush() throws IOException
This method flushes the output stream, resulting in any buffered data being written to the underlying output stream.
Throws: IOException if an I/O error occurs.

writeBufferedOutputStream

public void write(byte b[], int off, int len) throws IOException
This method writes len bytes to the buffered output stream from the byte array b beginning off bytes into the array.
Parameters:
b-the byte array from which the data is written.
off-the starting offset into the array for the data to be read from.
len-the number of bytes to write.
Throws: IOException if an I/O error occurs.

writeBufferedOutputStream

public void write(int b) throws IOException
This method writes a byte value to the buffered output stream.
Parameters: b-the byte value to be written.
Throws: IOException if an I/O error occurs.

ByteArrayInputStream

Extends: InputStream
This class implements an input stream whose data is read from an array of bytes.

Member Variables

protected byte buf[]

This is the buffer where data is stored.

protected int count

This is the number of bytes of data currently in the buffer.

protected int pos

This is the current read position in the buffer.

ByteArrayInputStream Constructor

public ByteArrayInputStream(byte b[])
This constructor creates a new input stream from the byte array b. Note that the byte array is not copied to create the stream.
Parameters: b-the byte array from which the data is read.

ByteArrayInputStream Constructor

public ByteArrayInputStream(byte b[], int off, int len)
This constructor creates a new input stream of size len from the byte array b beginning off bytes into the array. Note that the byte array is not copied to create the stream.
Parameters:
b-the byte array from which the data is read.
off-the starting offset into the array for the data to be read from.
len-the maximum number of bytes to read.

availableByteArrayInputStream

public int available()
This method determines the number of bytes that can be read from the input stream.
Returns: The number of available bytes.

readByteArrayInputStream

public int read()
This method reads a byte value from the input stream.
Returns: An integer representing the byte value read, or -1 if the end of the stream is reached.

readByteArrayInputStream

public int read(byte b[], int off, int len)
This method reads up to len bytes from the input stream into the byte array b beginning off bytes into the array.
Parameters:
b-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.

resetByteArrayInputStream

public void reset()
This method resets the read position to the beginning of the input stream.

skipByteArrayInputStream

public long skip(long n)
This method skips n bytes of data in the input stream.
Parameters: n-the number of bytes to skip.
Returns: The actual number of bytes skipped.

ByteArrayOutputStream

Extends: OutputStream

This class implements an output stream whose data is written to an array of bytes. The byte array automatically grows as data is written to it.

Member Variables

protected byte buf[]

This is the buffer where data is stored.

protected int count

This is the number of bytes of data currently in the buffer.

ByteArrayOutputStream Constructor

public ByteArrayOutputStream()
This constructor creates a new output stream with a default buffer size of 32 bytes. The size of the buffer automatically grows as data is written to it.

ByteArrayOutputStream Constructor

public ByteArrayOutputStream(int size)
This constructor creates a new output stream with an initial size of size bytes. The size of the buffer automatically grows as data is written to it.
Parameters: size-the initial size of the buffer.

resetByteArrayOutputStream

public void reset()
This method resets the contents of the underlying byte array by setting the count member variable to zero, resulting in the accumulated data being discarded.

sizeByteArrayOutputStream

public int size()
This method returns the current size of the buffer, which is stored in the count member variable.
Returns: The current size of the buffer.

toByteArrayByteArrayOutputStream

public byte[] toByteArray()
This method creates a new byte array containing the data currently stored in the underlying byte array associated with the output stream.
Returns: A byte array containing the current data stored in the output stream.

toStringByteArrayOutputStream

public String toString()
This method creates a new string containing the data currently stored in the underlying byte array associated with the output stream.
Returns: A string containing the current data stored in the output stream.

toStringByteArrayOutputStream

public String toString(int hibyte)
This method creates a new string containing the data currently stored in the underlying byte array associated with the output stream, with the top 8 bits of each string character set to hibyte.
Parameters: hibyte-the high byte value for each character.
Returns: A string containing the current data stored in the output stream, with the high byte of each character set to hibyte.

writeByteArrayOutputStream

public void write(byte b[], int off, int len)
This method writes len bytes to the output stream from the byte array b beginning off bytes into the array.
Parameters:
b-the byte array from which the data is written.
off-the starting offset into the array for the data to be read from.
len-the number of bytes to write.

writeByteArrayOutputStream

public void write(int b)
This method writes a byte value to the output stream.
Parameters: b-the byte value to be written.

writeToByteArrayOutputStream

public void writeTo(OutputStream out) throws IOException
This method writes the contents of the underlying byte array to another output stream.
Parameters: out-the output stream to write to.
Throws: IOException if an I/O error occurs.

DataInputStream

Extends: FilterInputStream
Implements: DataInput
This class implements an input stream that can read Java primitive data types in a platform-independent manner.

DataInputStream Constructor

public DataInputStream(InputStream in)
This method creates a new data input stream to read data from the in input stream.
Parameters: in-the input stream to read data from.

read

public final int read(byte b[]) throws IOException
This method reads up to b.length bytes from the data input stream into the byte array b, blocking until all bytes are read.
Parameters: b-the byte array into which the data is read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

read

public final int read(byte b[], int off, int len) throws IOException
This method reads up to len bytes from the data input stream into the byte array b beginning off bytes into the array, blocking until all bytes are read.
Parameters:
b-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

readBoolean

public final boolean readBoolean() throws IOException
This method reads a boolean value (byte) from the data input stream, blocking until the byte is read. A value of 0 is interpreted as false, and all other values are interpreted as true.
Returns: The boolean value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readByte

public final byte readByte() throws IOException
This method reads a signed byte (8-bit) value from the data input stream, blocking until the byte is read.
Returns: The byte value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readChar

public final char readChar() throws IOException
This method reads a character (16-bit) value from the data input stream, blocking until both bytes are read.
Returns: The character value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readDouble

public final double readDouble() throws IOException
This method reads a double (64-bit) value from the data input stream, blocking until all eight bytes are read.
Returns: The double value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readFloat

public final float readFloat() throws IOException
This method reads a float (32-bit) value from the data input stream, blocking until all four bytes are read.
Returns: The float value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readFully

public final void readFully(byte b[]) throws IOException
This method reads up to b.length bytes from the data input stream into the byte array b, blocking until all bytes are read.
Parameters: b-the byte array into which the data is read.
Throws: EOFException if the end of the stream is reached before reading the specified number of bytes.
Throws: IOException if an I/O error occurs.

readFully

public final void readFully(byte b[], int off, int len) throws IOException
This method reads up to len bytes from the data input stream into the byte array b beginning off bytes into the array, blocking until all bytes are read.
Parameters:
b-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Throws: EOFException if the end of the stream is reached before reading the specified number of bytes.
Throws: IOException if an I/O error occurs.

readInt

public final int readInt() throws IOException
This method reads an integer (32-bit) value from the data input stream, blocking until all four bytes are read.
Returns: The integer value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readLine

public final String readLine() throws IOException
This method reads a line of text from the data input stream, blocking until either a newline character ('\n') or a carriage return character ('\r') is read.
Returns: A string containing the line of text read.
Throws: EOFException if the end of the stream is reached before reading the line of text.
Throws: IOException if an I/O error occurs.

readLong

public final long readLong() throws IOException
This method reads a long (64-bit) value from the data input stream, blocking until all eight bytes are read.
Returns: The long value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readShort

public final short readShort() throws IOException
This method reads a signed short (16-bit) value from the data input stream, blocking until both bytes are read.
Returns: The short value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readUnsignedByte

public final int readUnsignedByte() throws IOException
This method reads an unsigned byte (8-bit) value from the data input stream, blocking until the byte is read.
Returns: The unsigned byte value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readUnsignedShort

public final int readUnsignedShort() throws IOException
This method reads an unsigned short (16-bit) value from the data input stream, blocking until both bytes are read.
Returns: The unsigned short value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readUTF

public final String readUTF() throws IOException
This method reads a string that has been encoded using a modified UTF-8 format from the data input stream, blocking until all bytes are read.
Returns: The string read.
Throws: EOFException if the end of the stream is reached before reading the string.
Throws: UTFDataFormatException if the bytes read do not represent a valid UTF-8 encoding of a string.
Throws: IOException if an I/O error occurs.

readUTF

public final static String readUTF(DataInput in) throws IOException
This method reads a string from the in data input stream that has been encoded using a modified UTF-8 format, blocking until all bytes are read.
Parameters: in-the data input stream to read the string from.
Returns: The string read.
Throws: EOFException if the end of the stream is reached before reading the string.
Throws: UTFDataFormatException if the bytes read do not represent a valid UTF-8 encoding of a string.
Throws: IOException if an I/O error occurs.

skipBytes

public final int skipBytes(int n) throws IOException
This method skips n bytes of data in the data input stream, blocking until all bytes are skipped.
Parameters: n-the number of bytes to skip.
Returns: The actual number of bytes skipped.
Throws: EOFException if the end of the stream is reached before skipping the specified number of bytes.
Throws: IOException if an I/O error occurs.

DataOutputStream

Extends: FilterOutputStream
Implements: DataOutput
This class implements an output stream that can write Java primitive data types in a platform-independent manner.

Member Variables

protected int written
This is the number of bytes written to the output stream thus far.

DataOutputStream Constructor

public DataOutputStream(OutputStream out)
This method creates a new data output stream to write data to the out output stream.
Parameters: out-the output stream to write data to.

flush

public void flush() throws IOException
This method flushes the data output stream, resulting in any buffered data being written to the underlying output stream.
Throws: IOException if an I/O error occurs.

size

public final int size()
This method returns the number of bytes written to the data output stream thus far, which is stored in the written member variable.
Returns: The number of bytes written to the data output stream thus far.

write

public void write(byte b[], int off, int len) throws IOException
This method writes len bytes to the data output stream from the byte array b beginning off bytes into the array.
Parameters:
b-the byte array from which the data is written.
off-the starting offset into the array for the data to be read from.
len-the number of bytes to write.
Throws: IOException if an I/O error occurs.

write

public void write(int b) throws IOException
This method writes a byte value to the data output stream.
Parameters:
b-the byte value to be written.
IOException if an I/O error occurs.

writeBoolean

public final void writeBoolean(boolean v) throws IOException
This method writes a boolean value to the data output stream. The boolean value true is written as the byte value 1, where false is written as the byte value 0.
Parameters: v-the boolean value to be written.
Throws: IOException if an I/O error occurs.

writeByte

public final void writeByte(int v) throws IOException
This method writes a byte (8-bit) value to the data output stream.
Parameters: v-the byte value to be written.
Throws: IOException if an I/O error occurs.

writeBytes

public final void writeBytes(String s) throws IOException
This method writes a string to the data output stream as a sequence of bytes.
Parameters: s-the string to be written as bytes.
Throws: IOException if an I/O error occurs.

writeChar

public final void writeChar(int v) throws IOException
This method writes a character (16-bit) value to the data output stream.
Parameters: v-the character value to be written.
Throws: IOException if an I/O error occurs.

writeChars

public final void writeChars(String s) throws IOException
This method writes a string to the data output stream as a sequence of characters.
Parameters: s-the string to be written as characters.
Throws: IOException if an I/O error occurs.

writeDouble

public final void writeDouble(double v) throws IOException
This method writes a double (64-bit) value to the data output stream.
Parameters: v-the double value to be written.
Throws: IOException if an I/O error occurs.

writeFloat

public final void writeFloat(float v) throws IOException
This method writes a float (32-bit) value to the data output stream.
Parameters: v-the float value to be written.
Throws: IOException if an I/O error occurs.

writeInt

public final void writeInt(int v) throws IOException
This method writes an integer (32-bit) value to the data output stream.
Parameters: v-the integer value to be written.
Throws: IOException if an I/O error occurs.

writeLong

public final void writeLong(long v) throws IOException
This method writes a long (64-bit) value to the data output stream.
Parameters: v-the long value to be written.
Throws: IOException if an I/O error occurs.

writeShort

public final void writeShort(int v) throws IOException
This method writes a short (16-bit) value to the data output stream.
Parameters: v-the short value to be written.
Throws: IOException if an I/O error occurs.

writeUTF

public final void writeUTF(String str) throws IOException
This method encodes a string using a modified UTF-8 format and writes it to the data output stream.
Parameters: str-the string to be written.
Throws: IOException if an I/O error occurs.

File

Extends: Object
This class implements a filename in a platform-independent manner. The File class provides the functionality necessary to work with filenames and directories without having to deal with the complexities associated with filenames on a particular platform.

Member Variables

public final static String pathSeparator

This is the platform-specific path separator string.

public final static char pathSeparatorChar

This is the platform-specific path separator character, which separates filenames in a path list.

public final static String separator

This is the platform-specific file separator string.

public final static char separatorChar

This is the platform-specific file separator character, which separates the file and directory components in a filename.

File Constructor

public File(File dir, String name)
This constructor creates a filename of an underlying file based on the specified directory and filename. If no directory is specified in the dir argument, the constructor assumes the file is in the current directory.
Parameters:
dir-the directory where the file is located.
name-the filename.

File Constructor

public File(String path)
This constructor creates a filename of an underlying file based on the specified file path.
Parameters: path-the file path.
Throws: NullPointerException if the file path is null.

File Constructor

public File(String path, String name)
This constructor creates a filename of an underlying file based on the specified path and filename.
Parameters: path-the path where the file is located.
Parameters: name-the filename.

canRead

public boolean canRead()
This method determines if the underlying file can be read from. In other words, if the file is readable canRead determines if the file exists.
Returns: true if the file can be read from; false otherwise.
Throws: SecurityException if the application doesn't have read access to the file.

canWrite

public boolean canWrite()
This method determines if the underlying file can be written to. In other words, if the file is writable canWrite determines if the file exists.
Returns: true if the file can be written to; false otherwise.
Throws: SecurityException if the application doesn't have write access to the file.

delete

public boolean delete()
This method deletes the underlying file.
Returns: true if the file is deleted; false otherwise.
Throws: SecurityException if the application doesn't have access to delete the file.

equals

public boolean equals(Object obj)
This method compares the pathname of the obj File object to the pathname of the underlying file.
Parameters: obj-the object to compare with.
Returns: true if the pathnames are equal; false otherwise.

exists

public boolean exists()
This method determines if the underlying file exists by opening it for reading and then clos-ing it.
Returns: true if the file exists; false otherwise.
Throws: SecurityException if the application doesn't have read access to the file.

getAbsolutePath

public String getAbsolutePath()
This method determines the platform-specific absolute pathname of the underlying file.
Returns: The absolute pathname of the file.

getName

public String getName()
This method determines the filename of the underlying file, which doesn't include any path information.
Returns: The filename of the file.

getParent

public String getParent()
This method determines the parent directory of the underlying file, which is the immediate directory where the file is located.
Returns: The parent directory of the file, or null if the file is located in the root directory.

getPath

public String getPath()
This method determines the pathname of the underlying file.
Returns: The pathname of the file.

hashCode

public int hashCode()
This method calculates a hash code for the underlying file.
Returns: A hash code for the file.

isAbsolute

public boolean isAbsolute()
This method determines if this object represents an absolute pathname for the underlying file. Note that absolute pathnames are platform specific.
Returns: true if the pathname for the file is absolute; false otherwise.

isDirectory

public boolean isDirectory()
This method determines if the underlying file is actually a directory.
Returns: true if the file is actually a directory; false otherwise.
Throws: SecurityException if the application doesn't have read access to the file.

isFile

public boolean isFile()
This method determines if the underlying file is a normal file; i.e. not a directory.
Returns: true if the file is a normal file; false otherwise.
Throws: SecurityException if the application doesn't have read access to the file.

lastModified

public long lastModified()
This method determines the last modification time of the underlying file. Note that this time is system-specific and is not absolute; in other words, only use the time to compare against other times retrieved using this method.
Returns: The last modification time of the file, or 0 if the file doesn't exist.
Throws: SecurityException if the application doesn't have read access to the file.

length

public long length()
This method determines the length in bytes of the underlying file.
Returns: The length of the file in bytes.
Throws: SecurityException if the application doesn't have read access to the file.

list

public String[] list()
This method builds a list of the filenames located in the directory represented by this object. Note that the underlying file must actually be a directory for this method to work.
Returns: An array containing the filenames located in the directory.
Throws: SecurityException if the application doesn't have read access to the file.

list

public String[] list(FilenameFilter filter)
This method builds a list of the filenames located in the directory represented by this object using the specified filename filter. Note that the underlying file must actually be a directory for this method to work.
Parameters: filter-the filename filter used to select the filenames.
Returns: An array containing the filtered filenames located in the directory.
Throws: SecurityException if the application doesn't have read access to the file.

mkdir

public boolean mkdir()
This method creates a directory based on the pathname specified by this object.
Returns: true if the directory is created; false otherwise.
Throws: SecurityException if the application doesn't have write access to the file.

mkdirs

public boolean mkdirs()
This method creates a directory based on the pathname specified by this object, including all necessary parent directories.
Returns: true if the directory (or directories) is created; false otherwise.
Throws: SecurityException if the application doesn't have write access to the file.

renameTo

public boolean renameTo(File dest)
This method renames the underlying file to the filename specified by the dest file object.
Parameters: dest-the new filename.
Returns: true if the file is renamed; false otherwise.
Throws: SecurityException if the application doesn't have write access to both the underlying file and the file represented by the dest file object.

toString

public String toString()
This method determines a string representation of the pathname for the underlying file.
Returns: A string representing the pathname of the file.

FileDescriptor

Extends: Object
This class implements a handle to a platform-specific file or socket structure. FileDescriptor objects are primarily used internally by the Java system and are never created by an application directly.

Member Variables

public final static FileDescriptor err

This is a handle to the standard error stream.

public final static FileDescriptor in

This is a handle to the standard input stream.

public final static FileDescriptor out

This is a handle to the standard output stream.

FileDescriptor Constructor

public FileDescriptor()
This constructor creates a default FileDescriptor object.

valid

public boolean valid()
This method determines whether this object represents a valid open file or socket.
Returns: true if the underlying file or socket is valid; false otherwise.

FileInputStream

Extends: InputStream
This class implements an input stream for reading data from a file or file descriptor.

FileInputStream Constructor

public FileInputStream(File file) throws FileNotFoundException
This constructor creates a file input stream to read data from the specified file.
Parameters: file-the file to be opened for reading.
Throws: FileNotFoundException if the file is not found.
Throws: SecurityException if the application doesn't have read access to the file.

FileInputStream Constructor

public FileInputStream(FileDescriptor fdObj)
This constructor creates a file input stream to read data from the file represented by the specified file descriptor.
Parameters: fdObj-the file descriptor representing the file to be opened for reading.
Throws: SecurityException if the application doesn't have read access to the file.

FileInputStream Constructor

public FileInputStream(String name) throws FileNotFoundException
This constructor creates a file input stream to read data from the file with the specified filename.
Parameters: name-the filename of the file to be opened for reading.
Throws: FileNotFoundException if the file is not found.
Throws: SecurityException if the application doesn't have read access to the file.

available

public int available() throws IOException
This method determines the number of bytes that can be read from the file input stream without blocking.
Returns: The number of available bytes.
Throws: IOException if an I/O error occurs.

close

public void close() throws IOException
This method closes the file input stream, releasing any resources associated with the stream.
Throws: IOException if an I/O error occurs.

finalize

protected void finalize() throws IOException
This method makes sure the close method is called when the file input stream is cleaned up by the Java garbage collector.
Throws: IOException if an I/O error occurs.

getFD

public final FileDescriptor getFD() throws IOException
This method determines the file descriptor associated with the file input stream.
Returns: The file descriptor associated with the stream.
Throws: IOException if an I/O error occurs.

read

public int read() throws IOException
This method reads a byte value from the file input stream, blocking until the byte is read.
Returns: An integer representing the byte value read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

read

public int read(byte b[]) throws IOException
This method reads up to b.length bytes from the file input stream into the byte array b, blocking until all bytes are read.
Parameters: b-the byte array into which the data is read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

read

public int read(byte b[], int off, int len) throws IOException
This method reads up to len bytes from the file input stream into the byte array b beginning off bytes into the array, blocking until all bytes are read.
Parameters:
b-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

skip

public long skip(long n) throws IOException
This method skips n bytes of data in the file input stream.
Parameters: n-the number of bytes to skip.
Returns: The actual number of bytes skipped.
Throws: IOException if an I/O error occurs.

FileOutputStream

Extends: OutputStream
This class implements an output stream for writing data to a file or file descriptor.

FileOutputStream

public FileOutputStream(File file) throws IOException
This constructor creates a file output stream to write data to the specified file.
Parameters: file-the file to be opened for writing.
Throws: FileNotFoundException if the file could not be opened for writing.
Throws: SecurityException if the application doesn't have write access to the file.

FileOutputStream Constructor

public FileOutputStream(FileDescriptor fdObj)
This constructor creates a file output stream to write data to the file represented by the specified file descriptor.
Parameters: fdObj-the file descriptor representing the file to be opened for writing.
Throws: SecurityException if the application doesn't have write access to the file.

FileOutputStream Constructor

public FileOutputStream(String name) throws IOException
This constructor creates a file output stream to write data to the file with the specified filename.
Parameters: name-the filename of the file to be opened for writing.
Throws: FileNotFoundException if the file is not found.
Throws: SecurityException if the application doesn't have read access to the file.

close

public void close() throws IOException
This method closes the file output stream, releasing any resources associated with the stream.
Throws: IOException if an I/O error occurs.

finalize

protected void finalize() throws IOException
This method makes sure the close method is called when the file output stream is cleaned up by the Java garbage collector.
Throws: IOException if an I/O error occurs.

getFD

public final FileDescriptor getFD() throws IOException
This method determines the file descriptor associated with the file output stream.
Returns: The file descriptor associated with the stream.
Throws: IOException if an I/O error occurs.

write

public void write(byte b[]) throws IOException
This method writes b.length bytes to the file output stream from the byte array b.
Parameters: b-the byte array from which the data is written.
Throws: IOException if an I/O error occurs.
write
public void write(byte b[], int off, int len) throws IOException
This method writes len bytes to the file output stream from the byte array b beginning off bytes into the array.
Parameters:
b-the byte array from which the data is written.
off-the starting offset into the array for the data to be read from.
len-the number of bytes to write.
Throws: IOException if an I/O error occurs.

write

public void write(int b) throws IOException
This method writes a byte value to the file output stream.
Parameters: b-the byte value to be written.
Throws: IOException if an I/O error occurs.

FilterInputStream

Extends: InputStream
This class defines an input stream filter that can be used to filter data on an underlying input stream. Most of the methods defined in FilterInputStream simply call corresponding methods in the underlying input stream. You simply override appropriate methods to provide the filtering functionality. FilterInputStream serves as the basis for all other input stream filter implementations. Derived filtered input streams can be chained together to provide complex filtering operations.

Member Variables

protected InputStream in
This is the underlying input stream that is being filtered.

FilterInputStream Constructor

protected FilterInputStream(InputStream in)
This constructor creates a filtered input stream based on the specified underlying input stream.
Parameters: in-the input stream to be filtered.

available

public int available() throws IOException
This method determines the number of bytes that can be read from the filtered input stream without blocking.
Returns: The number of available bytes.
Throws: IOException if an I/O error occurs.

close

public void close() throws IOException
This method closes the filtered input stream, releasing any resources associated with the stream.
Throws: IOException if an I/O error occurs.

mark

public void mark(int readlimit)
This method marks the current read position in the filtered input stream. The reset method can be used to reset the read position to this mark; subsequent reads will read data beginning at the mark position. The mark position is invalidated after readlimit bytes have been read.
Parameters: readlimit-the maximum number of bytes that can be read before the mark position becomes invalid.

markSupported

public boolean markSupported()
This method determines if the filtered input stream supports the mark and reset methods.
Returns: true if the mark and reset methods are supported; false otherwise.

read

public int read() throws IOException
This method reads a byte value from the filtered input stream, blocking until the byte is read.
Returns: An integer representing the byte value read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

read

public int read(byte b[]) throws IOException
This method reads up to b.length bytes from the filtered input stream into the byte array b, blocking until all bytes are read.
Parameters: b-the byte array into which the data is read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

read

public int read(byte b[], int off, int len) throws IOException
This method reads up to len bytes from the filtered input stream into the byte array b beginning off bytes into the array, blocking until all bytes are read.
Parameters:
b-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

reset

public void reset() throws IOException
This method resets the read position in the input stream to the current mark position, as set by the mark method.
Throws: IOException if the stream has not been marked or if the mark is invalid.

skip

public long skip(long n) throws IOException
This method skips n bytes of data in the input stream.
Parameters: n-the number of bytes to skip.
Returns: The actual number of bytes skipped.
Throws: IOException if an I/O error occurs.

FilterOutputStream

Extends: OutputStream
This class defines an output stream filter that can be used to filter data on an underlying output stream. Most of the methods defined in FilterOutputStream simply call corresponding methods in the underlying output stream. You simply override appropriate methods to provide the filtering functionality. FilterOutputStream serves as the basis for all other output stream filter implementations. Derived filtered output streams can be chained together to provide complex filtering operations.

Member Variables

protected OutputStream out
This is the underlying output stream that is being filtered.

FilterOutputStream

public FilterOutputStream(OutputStream out)
This constructor creates a filtered output stream based on the specified underlying output stream.
Parameters: out-the output stream to be filtered.

close

public void close() throws IOException
This method closes the filtered output stream, releasing any resources associated with the stream.
Throws: IOException if an I/O error occurs.

flush

public void flush() throws IOException
This method flushes the filtered output stream, resulting in any buffered data being written to the underlying output stream.
Throws: IOException if an I/O error occurs.

write

public void write(byte b[]) throws IOException
This method writes b.length bytes to the filtered output stream from the byte array b.
Parameters: b-the byte array from which the data is written.
Throws: IOException if an I/O error occurs.

write

public void write(byte b[], int off, int len) throws IOException
This method writes len bytes to the filtered output stream from the byte array b beginning off bytes into the array, blocking until all bytes are written.
Parameters:
b-the byte array from which the data is written.
off-the starting offset into the array for the data to be read from.
len-the number of bytes to write.
Throws: IOException if an I/O error occurs.

write

public void write(int b) throws IOException
This method writes a byte value to the buffered output stream.
Parameters: b-the byte value to be written.
Throws: IOException if an I/O error occurs.

InputStream

Extends: Object
This class is an abstract class representing an input stream of bytes. All input streams are based on InputStream.

InputStream Constructor

public InputStream()
This constructor creates a default input stream.

available

public int available() throws IOException
This method determines the number of bytes that can be read from the input stream without blocking. This method should be overridden in all subclasses, as it returns 0 in InputStream.
Returns: The number of available bytes.
Throws: IOException if an I/O error occurs.

close

public void close() throws IOException
This method closes the input stream, releasing any resources associated with the stream. This method should usually be overridden in subclasses, as it does nothing in InputStream.
Throws: IOException if an I/O error occurs.

mark

public void mark(int readlimit)
This method marks the current read position in the input stream. The reset method can be used to reset the read position to this mark; subsequent reads will read data beginning at the mark position. The mark position is invalidated after readlimit bytes have been read. This method should usually be overridden in subclasses, as it does nothing in InputStream.
Parameters: readlimit-the maximum number of bytes that can be read before the mark position becomes invalid.

markSupported

public boolean markSupported()
This method determines if the input stream supports the mark and reset methods. This method should usually be overridden in subclasses, as it always returns false in InputStream.
Returns: true if the mark and reset methods are supported; false otherwise.

read

public abstract int read() throws IOException
This method reads a byte value from the input stream, blocking until the byte is read. This method must be overridden in all subclasses, as it is defined as abstract in InputStream.
Returns: An integer representing the byte value read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

read

public int read(byte b[]) throws IOException
This method reads up to b.length bytes from the input stream into the byte array b, blocking until all bytes are read. This method actually calls the three-parameter version of read passing b, 0, and b.length as the parameters.
Parameters: b-the byte array into which the data is read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

read

public int read(byte b[], int off, int len) throws IOException
This method reads up to len bytes from the input stream into the byte array b beginning off bytes into the array, blocking until all bytes are read. This method actually reads each byte by calling the read method that takes no parameters. Subclasses should provide a more efficient implementation of this method that isn't reliant on the other read method if possible.
Parameters:
b-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

reset

public void reset() throws IOException
This method resets the read position in the input stream to the current mark position, as set by the mark method. This method should be overridden in subclasses requiring mark/reset functionality, as it always throws an IOException in InputStream; this is a result of the fact that input streams don't support mark/reset functionality by default.
Throws: IOException if the stream has not been marked or if the mark is invalid.

skip

public long skip(long n) throws IOException
This method skips n bytes of data in the input stream. This method should usually be overridden with a more efficient version in subclasses, as it reads skipped data into a temporary byte array in InputStream.
Parameters: n-the number of bytes to skip.
Returns: The actual number of bytes skipped.
Throws: IOException if an I/O error occurs.

LineNumberInputStream

Extends: FilterInputStream
This class implements an input stream that keeps track of how many lines have passed through the stream. A line is defined as a sequence of bytes followed by either a carriage return character ('\r'), a newline character ('\n'), or a carriage return character immediately followed by a newline character. In all three cases, the new line is interpreted as a single character.

LineNumberInputStream Constructor

public LineNumberInputStream(InputStream in)
This constructor creates a line number input stream that counts lines based on the specified input stream.
Parameters: in-the input stream to count lines from.

available

public int available() throws IOException
This method determines the number of bytes that can be read from the input stream without blocking. Note that this number could be as little as half as large as that of the underlying stream, since LineNumberInputStream combines carriage return/newline character pairs into a single new line byte.
Returns: The number of available bytes.

getLineNumber

public int getLineNumber()
This method determines the current line number for the input stream, which is the count of how many lines the stream has processed.
Returns: The current line number.

mark

public void mark(int readlimit)
This method marks the current read position in the input stream. The reset method can be used to reset the read position to this mark; subsequent reads will read data beginning at the mark position. The mark position is invalidated after readlimit bytes have been read. mark makes sure to store away the current line number so it isn't invalidated by a subsequent call to reset.
Parameters: readlimit-the maximum number of bytes that can be read before the mark position becomes invalid.

read

public int read() throws IOException
This method reads a byte value from the input stream, blocking until the byte is read.
Returns: An integer representing the byte value read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

read

public int read(byte b[], int off, int len) throws IOException
This method reads up to len bytes from the input stream into the byte array b beginning off bytes into the array, blocking until all bytes are read.
Parameters:
b-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

reset

public void reset() throws IOException
This method resets the read position in the input stream to the current mark position, as set by the mark method. The current line number is reset to the value it held when the mark method was called.

setLineNumber

public void setLineNumber(int lineNumber)
This method sets the current line number to the specified line number.
Parameters: lineNumber-the new line number to be set.

skip

public long skip(long n) throws IOException
This method skips n bytes of data in the input stream.
Parameters: n-the number of bytes to skip.
Returns: The actual number of bytes skipped.
Throws: IOException if an I/O error occurs.

OutputStream

Extends: Object
This class is an abstract class representing an output stream of bytes. All output streams are based on OutputStream.

OutputStream Constructor

public OutputStream()
This constructor creates a default output stream.

close

public void close() throws IOException
This method closes the output stream, releasing any resources associated with the stream. This method should usually be overridden in subclasses, as it does nothing in OutputStream.
Throws: IOException if an I/O error occurs.

flush

public void flush() throws IOException
This method flushes the output stream, resulting in any buffered data being written to the underlying output stream. This method should usually be overridden in subclasses, as it does nothing in OutputStream.
Throws: IOException if an I/O error occurs.

write

public void write(byte b[]) throws IOException
This method writes b.length bytes to the output stream from the byte array b. This method actually calls the three-parameter version of write passing b, 0, and b.length as the parameters.
Parameters: b-the byte array from which the data is written.
Throws: IOException if an I/O error occurs.

write

public void write(byte b[], int off, int len) throws IOException
This method writes len bytes to the output stream from the byte array b beginning off bytes into the array. This method actually writes each byte by calling the write method that takes one parameter. Subclasses should provide a more efficient implementation of this method that isn't reliant on the other write method if possible.
Parameters:
b-the byte array from which the data is written.
off-the starting offset into the array for the data to be read from.
len-the number of bytes to write.
Throws: IOException if an I/O error occurs.

write

public abstract void write(int b) throws IOException
This method writes a byte value to the output stream. This method must be overridden in all subclasses, as it is defined as abstract in OutputStream.
Parameters: b-the byte value to be written.
Throws: IOException if an I/O error occurs.

PipedInputStream

Extends: InputStream
This class implements a piped input stream, which acts as the receiving end of a communications pipe. Piped input streams must be connected to a piped output stream to receive data. In other words, a piped output stream must be used to send the data received by a piped input stream.

PipedInputStream Constructor

public PipedInputStream()
This constructor creates a piped input stream that isn't connected to anything. The stream must be connected to a piped output stream via the connect method before it can be used.

PipedInputStream Constructor

public PipedInputStream(PipedOutputStream src) throws IOException
This constructor creates a piped input stream that is connected to the specified piped output stream.
Parameters: src-the piped output stream to connect to.
Throws: IOException if an I/O error occurs.

close

public void close() throws IOException
This method closes the piped input stream, releasing any resources associated with the stream.
Throws: IOException if an I/O error occurs.

connect

public void connect(PipedOutputStream src) throws IOException
This method connects the input stream to the specified piped output stream.
Parameters: src-the piped output stream to connect to.
Throws: IOException if an I/O error occurs.

read

public int read() throws IOException
This method reads a byte value from the piped input stream, blocking until the byte is read.
Returns: An integer representing the byte value read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

read

public int read(byte b[], int off, int len) throws IOException
This method reads up to len bytes from the piped input stream into the byte array b beginning off bytes into the array, blocking until all bytes are read.
Parameters:
b-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

PipedOutputStream

Extends: OutputStream
This class implements a piped output stream, which acts as the sending end of a communications pipe. Piped output streams must be connected to a piped input stream to send data. In other words, a piped input stream must be used to receive the data sent by a piped output stream.

PipedOutputStream Constructor

public PipedOutputStream()
This constructor creates a piped output stream that isn't connected to anything. The stream must be connected to a piped input stream via the connect method before it can be used.

PipedOutputStream Constructor

public PipedOutputStream(PipedInputStream snk) throws IOException
This constructor creates a piped output stream that is connected to the specified piped input stream.
Parameters: snk-the piped input stream to connect to.
Throws: IOException if an I/O error occurs.

close

public void close() throws IOException
This method closes the piped output stream, releasing any resources associated with the stream.
Throws: IOException if an I/O error occurs.

connect

public void connect(PipedInputStream snk) throws IOException
This method connects the output stream to the specified piped input stream.
Parameters: snk-the piped input stream to connect to.
Throws: IOException if an I/O error occurs.

write

public void write(byte b[], int off, int len) throws IOException
This method writes len bytes to the piped output stream from the byte array b beginning off bytes into the array.
Parameters:
b-the byte array from which the data is written.
off-the starting offset into the array for the data to be read from.
len-the number of bytes to write.
Throws: IOException if an I/O error occurs.

write

public void write(int b) throws IOException
This method writes a byte value to the piped output stream.
Parameters: b-the byte value to be written.
Throws: IOException if an I/O error occurs.

PrintStream

Extends: FilterOutputStream
This class implements an output stream that has additional methods for printing basic types of data. You can set up the stream so that it is flushed every time a newline character ('\n') is written. Note that only the lower 8 bits of any 16-bit value are printed to the stream.

PrintStream Constructor

public PrintStream(OutputStream out)
This constructor creates a print stream that writes data to the specified underlying output stream.
Parameters: out-the output stream to be written to.

PrintStream Constructor

public PrintStream(OutputStream out, boolean autoflush)
This constructor creates a print stream that writes data to the specified underlying output stream, with an option of flushing its output each time a newline character ('\n') is encountered.
Parameters:
out-the output stream to be written to.
autoflush-a boolean value specifying whether the stream is flushed when a newline character is encountered.

checkError

public boolean checkError()
This method flushes the underlying output stream and determines whether an error has occurred on the stream. Note that errors are cumulative, meaning that once an error is encountered, checkError will continue to return true on all successive calls.
Returns: true if the print stream has ever encountered an error on the underlying output stream; false otherwise.
public void close()
This method closes the print stream, releasing any resources associated with the underlying output stream.

flush

public void flush()
This method flushes the print stream, resulting in any buffered data being written to the underlying output stream.

print

public void print(boolean b)
This method prints the string representation of a boolean value to the underlying output stream. If the boolean value is true, the string "true" is printed; otherwise, the string "false" is printed.
Parameters: b-the boolean value to be printed.

print

public void print(char c)
This method prints the lower 8 bits of a character value to the underlying output stream.
Parameters: c-the character value to be printed.

print

public void print(char s[])
This method prints the lower 8 bits of each character value in an array of characters to the underlying output stream.
Parameters: s-the array of characters to be printed.

print

public void print(double d)
This method prints the string representation of a double value to the underlying output stream. Note that the string representation is the same as that returned by the toString method of the Double class.
Parameters: d-the double value to be printed.

print

public void print(float f)
This method prints the string representation of a float value to the underlying output stream. Note that the string representation is the same as that returned by the toString method of the Float class.
Parameters: f-the float value to be printed.

print

public void print(int i)
This method prints the string representation of an integer value to the underlying output stream. Note that the string representation is the same as that returned by the toString method of the Integer class.
Parameters: i-the integer value to be printed.

print

public void print(long l)
This method prints the string representation of a long value to the underlying output stream. Note that the string representation is the same as that returned by the toString method of the Long class.
Parameters: l-the long value to be printed.

print

public void print(Object obj)
This method prints the string representation of an object to the underlying output stream. Note that the string representation is the same as that returned by the toString method of the object.
Parameters: obj-the object to be printed.

print

public void print(String s)
This method prints the lower 8 bits of each character in a string to the underlying output stream. If the string is null, the string "null" is printed.
Parameters: s-the string to be printed.

println

public void println()
This method prints the newline character ('\n') to the underlying output stream.

println

public void println(boolean b)
This method prints the string representation of a boolean value to the underlying output stream, followed by a newline character ('\n'). If the boolean value is true, the string "true" is printed; otherwise, the string "false" is printed.
Parameters: b-the boolean value to be printed.

println

public void println(char c)
This method prints the lower 8 bits of a character value to the underlying output stream, followed by a newline character.
Parameters: c-the character value to be printed

println

public void println(char s[])
This method prints the lower 8 bits of each character value in an array of characters to the underlying output stream, followed by a newline character.
Parameters: s-the array of characters to be printed.

println

public void println(double d)
This method prints the string representation of a double value to the underlying output stream, followed by a newline character. Note that the string representation is the same as that returned by the toString method of the Double class.
Parameters: d-the double value to be printed.

println

public void println(float f)
This method prints the string representation of a float value to the underlying output stream, followed by a newline character. Note that the string representation is the same as that returned by the toString method of the Float class.
Parameters: f-the float value to be printed.

println

public void println(int i)
This method prints the string representation of an integer value to the underlying output stream, followed by a newline character. Note that the string representation is the same as that returned by the toString method of the Integer class.
Parameters: i-the integer value to be printed.

println

public void println(long l)
This method prints the string representation of a long value to the underlying output stream, followed by a newline character. Note that the string representation is the same as that returned by the toString method of the Long class.
Parameters: l-the long value to be printed.

println

public void println(Object obj)
This method prints the string representation of an object to the underlying output stream, followed by a newline character. Note that the string representation is the same as that returned by the toString method of the object.
Parameters: obj-the object to be printed.

println

public void println(String s)
This method prints the lower 8 bits of each character in a string to the underlying output stream, followed by a newline character. If the string is null, the string "null" is printed.
Parameters: s-the string to be printed.

write

public void write(byte b[], int off, int len)
This method writes len bytes to the underlying output stream from the byte array b beginning off bytes into the array.
Parameters:
b-the byte array from which the data is written.
off-the starting offset into the array for the data to be read from.
len-the number of bytes to write.

write

public void write(int b)
This method writes a byte value to the underlying output stream. The write method of the underlying output stream is actually called to write the byte value. Additionally, if the byte represents the newline character ('\n') and autoflush is turned on, the flush method is called.
If an IOException is thrown while writing the byte, the exception is caught and an internal error flag is set; this flag can be checked by calling the checkError method. This technique is used to alleviate having to use a try-catch clause every time you want to print something.
Parameters: b-the byte value to be written.
Throws: IOException if an I/O error occurs.

PushbackInputStream

Extends: FilterInputStream
This class implements a input stream filter that provides a one byte push back buffer. Using the PushbackInputStream class, an application can push the last byte read back into the stream so it will be re-read the next time the read method is called. This functionality is sometimes useful in situations where byte-delimited data is being read; the delimited bytes can be pushed back into the stream so the next read operation will read them.

Member Variables

protected int pushBack
This is the push back buffer containing the character that was pushed back. A value of -1 indicates that the push back buffer is empty.

PushbackInputStream Constructor

public PushbackInputStream(InputStream in)
This constructor creates a push back input stream using the specified underlying input stream.
Parameters: in-the input stream to use the push back filter on.

available

public int available() throws IOException
This method determines the number of bytes that can be read from the push back input stream without blocking.
Returns: The number of available bytes.
Throws: IOException if an I/O error occurs.

markSupported

public boolean markSupported()
This method determines if the push back input stream supports the mark and reset methods.
Returns: true if the mark and reset methods are supported; false otherwise.

read

public int read() throws IOException
This method reads a byte value from the push back input stream, blocking until the byte is read. The read method actually returns the push back character if there is one, and calls the underlying input stream's read method if not.
Returns: An integer representing the byte value read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

read

public int read(byte bytes[], int off, int len) throws IOException
This method reads up to len bytes from the buffered input stream into the byte array bytes beginning off bytes into the array, blocking until all bytes are read.
Parameters:
bytes-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

unread

public void unread(int ch) throws IOException
This method pushes a character back into the stream so that it is read the next time the read method is called. Note that there can only be one push back character, meaning that multiple calls to unread without matching calls to read will result in an IOException being thrown.
Parameters: ch-the character to push back into the stream.
Throws: IOException if an attempt is made to push back more than one character.

RandomAccessFile

Extends: Object
Implements: DataOutput, DataInput
This class implements a random access file stream, providing functionality for both reading from and writing to random access files.

RandomAccessFile Constructor

public RandomAccessFile(String name, String mode) throws IOException
This constructor creates a random access file stream based on the file with the specified filename and access mode. There are two supported access modes: Mode "r" is for read-only files and mode "rw" is for read/write files.
Parameters:
name-the filename of the file to access.
mode-the access mode.
Throws: IOException if an I/O error occurs.
Throws: IllegalArgumentException if the access mode is not equal to "r" or "rw".
Throws: SecurityException if the access mode is "r" and the application doesn't have read access to the file, or if the access mode is "rw" and the application doesn't have both read and write access to the file.

RandomAccessFile Constructor

public RandomAccessFile(File file, String mode) throws IOException
This constructor creates a random access file stream based on the specified file and access mode. There are two supported access modes: mode "r" is for read-only files and mode "rw" is for read/write files.
Parameters:
file-the file to access.
mode-the access mode.
Throws: IOException if an I/O error occurs.
Throws: IllegalArgumentException if the access mode is not equal to "r" or "rw".
Throws: SecurityException if the access mode is "r" and the application doesn't have read access to the file, or if the access mode is "rw" and the application doesn't have both read and write access to the file.

close

public void close() throws IOException
This method closes the random access file stream, releasing any resources associated with the stream.
Throws: IOException if an I/O error occurs.

getFD

public final FileDescriptor getFD() throws IOException
This method determines the file descriptor associated with the random access file stream.
Returns: The file descriptor associated with the stream.
Throws: IOException if an I/O error occurs.

getFilePointer

public long getFilePointer() throws IOException
This method determines the current read/write position in bytes of the random access file stream, which is the offset of the read/write position from the beginning of the stream.
Returns: The current read/write position of the stream.
Throws: IOException if an I/O error occurs.

length

public long length() throws IOException
This method determines the length in bytes of the underlying file.
Returns: The length of the underlying file.
Throws: IOException if an I/O error occurs.

read

public int read() throws IOException
This method reads a byte value from the random access file stream, blocking until the byte is read.
Returns: An integer representing the byte value read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

read

public int read(byte b[]) throws IOException
This method reads up to b.length bytes from the random access file stream into the byte array b, blocking until at least one byte is available.
Parameters: b-the byte array into which the data is read.
Returns: The total number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

read

public int read(byte b[], int off, int len) throws IOException
This method reads up to len bytes from the random access file stream into the byte array b beginning off bytes into the array, blocking until at least one byte is available.
Parameters:
b-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Returns: The total number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

readBoolean

public final boolean readBoolean() throws IOException
This method reads a boolean value (byte) from the random access file stream. A value of 0 is interpreted as false, while all other values are interpreted as true.
Returns: The boolean value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readByte

public final byte readByte() throws IOException
This method reads a signed byte (8-bit) value from the random access file stream, blocking until the byte is read.
Returns: The byte value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readChar

public final char readChar() throws IOException
This method reads a character (16-bit) value from the random access file stream, blocking until both bytes are read.
Returns: The character value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readDouble

public final double readDouble() throws IOException
This method reads a double (64-bit) value from the random access file stream, blocking until all eight bytes are read.
Returns: The double value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readFloat

public final float readFloat() throws IOException
This method reads a float (32-bit) value from the random access file stream, blocking until all four bytes are read.
Returns: The float value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readFully

public final void readFully(byte b[]) throws IOException
This method reads up to b.length bytes from the random access file stream into the byte array b, blocking until all bytes are read.
Parameters: b-the byte array into which the data is read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readFully

public final void readFully(byte b[], int off, int len) throws IOException
This method reads up to len bytes from the random access file stream into the byte array b beginning off bytes into the array, blocking until all bytes are read.
Parameters:
b-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readInt

public final int readInt() throws IOException
This method reads an integer (32-bit) value from the random access file stream, blocking until all four bytes are read.
Returns: The integer value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readLine

public final String readLine() throws IOException
This method reads a line of text from the random access file stream, blocking until either a newline character ('\n') or a carriage return character ('\r') is read.
Returns: A string containing the line of text read.
Throws: IOException if an I/O error occurs.

readLong

public final long readLong() throws IOException
This method reads a long (64-bit) value from the random access file stream, blocking until all eight bytes are read.
Returns: The long value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readShort

public final short readShort() throws IOException
This method reads a short (16-bit) value from the random access file stream, blocking until both bytes are read.
Returns: The short value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readUnsignedByte

public final int readUnsignedByte() throws IOException
This method reads an unsigned byte (8-bit) value from the random access file stream, blocking until the byte is read.
Returns: The unsigned byte value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readUnsignedShort

public final int readUnsignedShort() throws IOException
This method reads an unsigned short (16-bit) value from the random access file stream, blocking until both bytes are read.
Returns: The unsigned short value read.
Throws: EOFException if the end of the stream is reached before reading the value.
Throws: IOException if an I/O error occurs.

readUTF

public final String readUTF() throws IOException
This method reads a string that has been encoded using a modified UTF-8 format from the random access file stream, blocking until all bytes are read.
Returns: The string read.
Throws: EOFException if the end of the stream is reached before reading the string.
Throws: UTFDataFormatException if the bytes read do not represent a valid UTF-8 encoding of a string.
Throws: IOException if an I/O error occurs.

seek

public void seek(long pos) throws IOException
This method sets the current stream position to the specified absolute position. The position is absolute because it is always relative to the beginning of the stream.
Parameters: pos-the absolute position to seek to.
Throws: IOException if an I/O error occurs.

skipBytes

public int skipBytes(int n) throws IOException
This method skips n bytes of data in the random access file stream, blocking until all bytes are skipped.
Parameters: n-the number of bytes to skip.
Returns: The actual number of bytes skipped.
Throws: EOFException if the end of the stream is reached before skipping the specified number of bytes.
Throws: IOException if an I/O error occurs.

write

public void write(byte b[]) throws IOException
This method writes b.length bytes to the random access file stream from the byte array b.
Parameters: b-the byte array from which the data is written.
Throws: IOException if an I/O error occurs.

write

public void write(byte b[], int off, int len) throws IOException
This method writes len bytes to the random access file stream from the byte array b beginning off bytes into the array.
Parameters:
b-the byte array from which the data is written.
off-the starting offset into the array for the data to be read from.
len-the number of bytes to write.
Throws: IOException if an I/O error occurs.

write

public void write(int b) throws IOException
This method writes a byte value to the random access file stream.
Parameters: b-the byte value to be written.
Throws: IOException if an I/O error occurs.

writeBoolean

public final void writeBoolean(boolean v) throws IOException
This method writes a boolean value to the random access file stream. The boolean value true is written as the byte value 1, where false is written as the byte value 0.
Parameters: v-the boolean value to be written.
Throws: IOException if an I/O error occurs.

writeByte

public final void writeByte(int v) throws IOException
This method writes a byte (8-bit) value to the random access file stream.
Parameters: v-the byte value to be written.
Throws: IOException if an I/O error occurs.

writeBytes

public final void writeBytes(String s) throws IOException
This method writes a string to the random access file stream as a sequence of bytes.
Parameters: s-the string to be written as bytes.
Throws: IOException if an I/O error occurs.

writeChar

public final void writeChar(int v) throws IOException
This method writes a character (16-bit) value to the random access file stream.
Parameters: v-the character value to be written.
Throws: IOException if an I/O error occurs.

writeChars

public final void writeChars(String s) throws IOException
This method writes a string to the random access file stream as a sequence of characters.
Parameters: s-the string to be written as characters.
Throws: IOException if an I/O error occurs.

writeDouble

public final void writeDouble(double v) throws IOException
This method writes a double (64-bit) value to the random access file stream.
Parameters: v-the double value to be written.
Throws: IOException if an I/O error occurs.

writeFloat

public final void writeFloat(float v) throws IOException
This method writes a float (32-bit) value to the random access file stream.
Parameters: v-the float value to be written.
Throws: IOException if an I/O error occurs.

writeInt

public final void writeInt(int v) throws IOException
This method writes an integer (32-bit) value to the random access file stream.
Parameters: v-the integer value to be written.
Throws: IOException if an I/O error occurs.

writeLong

public final void writeLong(long v) throws IOException
This method writes a long (64-bit) value to the random access file stream.
Parameters: v-the long value to be written.
Throws: IOException if an I/O error occurs.

writeShort

public final void writeShort(int v) throws IOException
This method writes a short (16-bit) value to the random access file stream.
Parameters: v-the short value to be written.
Throws: IOException if an I/O error occurs.

writeUTF

public final void writeUTF(String str) throws IOException
This method encodes a string using a modified UTF-8 format and writes it to the random access file stream.
Parameters: str-the string to be written.
Throws: IOException if an I/O error occurs.

SequenceInputStream

Extends: InputStream
This class implements an input stream that can combine several input streams in a serial manner so that they function together like a single input stream. Each input stream comprising the sequence is read from in turn; the sequence input stream handles closing streams as they finish and switching to the next one.

SequenceInputStream Constructor

public SequenceInputStream(Enumeration e)
This constructor creates a sequence input stream containing the specified enumerated list of input streams.
Parameters: e-the list of input streams for the sequence.

SequenceInputStream Constructor

public SequenceInputStream(InputStream s1, InputStream s2)
This constructor creates a sequence input stream containing the two specified input streams.
Parameters:
s1-the first input stream in the sequence.
s2-the second input stream in the sequence.

close

public void close() throws IOException
This method closes the sequence input stream, releasing any resources associated with the stream. Additionally, this close method calls the close method for the substream currently being read from as well as the substreams that have yet to be read from.
Throws: IOException if an I/O error occurs.

read

public int read() throws IOException
This method reads a byte value from the currently active substream in the sequence input stream, blocking until the byte is read. If the end of the substream is reached, the close method is called on the substream and read begins reading from the next substream.
Returns: An integer representing the byte value read, or -1 if the end of the stream is reached.

read

public int read(byte b[], int pos, int len) throws IOException
This method reads up to len bytes from the currently active substream in the sequence input stream into the byte array b beginning off bytes into the array, blocking until all bytes are read. If the end of the substream is reached, the close method is called on the substream and read begins reading from the next substream.
Parameters:
b-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException if an I/O error occurs.

StreamTokenizer

Extends: Object
This class implements a string tokenizer stream, which parses an input stream into a stream of tokens. The StreamTokenizer class provides a variety of methods for establishing how the tokens are parsed. Each character read from the stream is evaluated as having zero or more of the following attributes: whitespace, alphabetic, numeric, string quote, or comment.

Member Variables

public double nval

This member variable holds a numeric token value whenever the ttype member variable is set to TT_NUMBER.

public String sval

This member variable holds a string representation of a word token whenever the ttype member variable is set to TT_WORD, or it holds the body of a quoted string token when ttype is set to a quote character.

public int ttype

This is the type of the current token, which can be one of the following:

public final static int TT_EOF

This is a constant token type representing the end-of-file token.

public final static int TT_EOL

This is a constant token type representing the end-of-line token.

public final static int TT_NUMBER

This is a constant token type identifying a numeric token; the actual numeric value is stored in nval.

public final static int TT_WORD

This is a constant token type identifying a word token; the actual word value is stored in sval.

StreamTokenizer Constructor

public StreamTokenizer(InputStream I)
This constructor creates a string tokenizer stream that parses the specified input stream. By default, the string tokenizer stream recognizes numbers, strings quoted with single and double quotes, all alphabetic characters, and comments preceded by a '/' character.
Parameters: I-the input stream to be parsed.

commentChar

public void commentChar(int ch)
This method establishes the specified character as starting single line comments.
Parameters: ch-the new single line comment character.

eolIsSignificant

public void eolIsSignificant(boolean flag)
This method establishes whether end-of-line characters are recognized as tokens.
Parameters: flag-a boolean value specifying whether end-of-line characters are treated as tokens; a value of true means end-of-line characters are treated as tokens, whereas a value of false means they are treated as whitespace.

lineno

public int lineno()
This method determines the current line number of the string tokenizer stream.
Returns: The current line number of the stream.

lowerCaseMode

public void lowerCaseMode(boolean flag)
This method establishes whether word tokens (TT_WORD) are forced to lowercase when they are parsed.
Parameters: flag-a boolean value specifying whether word tokens are forced to lowercase; a value of true means word tokens are forced to lowercase, whereas a value of false means they are left unmodified.

nextToken

public int nextToken() throws IOException
This method parses the next token from the underlying input stream. After the token is parsed, the ttype member variable is set to the type of the token, while the value of some tokens is contained in either the nval or sval member variables, depending on the token type.
Returns: The type of the token.
Throws: IOException if an I/O error occurs.

ordinaryChar

public void ordinaryChar(int ch)
This method establishes that the specified character is handled as an ordinary character by the tokenizer, meaning that the character is not interpreted as a comment character, word component, string delimiter, whitespace, or numeric character. Ordinary characters are parsed as single character tokens.
Parameters: ch-the character to be set as ordinary.

ordinaryChars

public void ordinaryChars(int low, int hi)
This method establishes that the characters in the specified range are handled as ordinary characters by the tokenizer, meaning that the characters are not interpreted as com-
ment characters, word components, string delimiters, whitespace, or numeric characters. Ordinary characters are parsed as single character tokens.
Parameters:
low-the low end of the ordinary character range.
hi-the high end of the ordinary character range.

parseNumbers

public void parseNumbers()
This method establishes that numbers should be parsed. When a number is parsed, the ttype member variable is set to TT_NUMBER, with the corresponding numeric value stored in nval.

pushBack

public void pushBack()
This method pushes the current token back into the string tokenizer stream, meaning that the next call to nextToken will result in this token being handled.

quoteChar

public void quoteChar(int ch)
This method establishes that matching pairs of the specified character be used to delimit string constants. When a string constant is parsed, the ttype member variable is set to the delimiting character, with the corresponding string body stored in sval.
Parameters: ch-the new string delimiter character.

resetSyntax

public void resetSyntax()
This method resets the syntax table so that all characters are considered ordinary. An ordinary character is a character that isn't interpreted as a comment character, word component, string delimiter, whitespace, or numeric character. Ordinary characters are parsed as single character tokens.

slashSlashComments

public void slashSlashComments(boolean flag)
This method establishes whether C++ style comments (//) are recognized by the parser. A C++ style comment is defined by two consecutive forward slash characters, which starts a comment that extends to the end of the line.
Parameters: flag-a boolean value specifying whether C++ style comments are recognized; a value of true means C++ style comments are recognized, whereas a value of false means they are not treated specially.

slashStarComments

public void slashStarComments(boolean flag)
This method establishes whether C style comments (/*...*/) are recognized by the parser. A C style comment is defined by a forward slash character followed by an asterisk, which starts a comment. The comment continues until a corresponding asterisk followed by a forward slash character is reached.
Parameters: flag-a boolean value specifying whether C style comments are recognized; a value of true means C style comments are recognized, whereas a value of false means they are not treated specially.

toString

public String toString()
This method determines the string representation of the current token in the string tokenizer stream.
Returns: The string representation of the current token.

whitespaceChars

public void whitespaceChars(int low, int hi)
This method establishes that the characters in the specified range are handled as whitespace by the tokenizer, meaning that the characters serve only to separate tokens.
Parameters:
low-the low end of the whitespace character range.
hi-the high end of the whitespace character range.

wordChars

public void wordChars(int low, int hi)
This method establishes that the characters in the specified range are handled as words by the tokenizer.
Parameters: low-the low end of the word character range.
Parameters: hi-the high end of the word character range.

StringBufferInputStream

Extends: InputStream
This class implements an input stream whose data is fed by a string. Note that only the lower 8 bits of each character in the string are used by this class.

Member Variables

protected String buffer

This is the string buffer from which the data is read.

protected int count

This is the number of characters currently in the buffer.

protected int pos

This is the current read position in the buffer.

StringBufferInputStream Constructor

public StringBufferInputStream(String s)
This constructor creates a string buffer input stream based on the specified string. Note that the string buffer is not copied to create the input stream.
Parameters: s-the input string buffer.

available

public int available()
This method determines the number of bytes that can be read from the string buffer input stream without blocking.
Returns: The number of available bytes.

read

public int read()
This method reads a byte value from the string buffer input stream, which is the lower 8 bits of the next character in the underlying string buffer.
Returns: An integer representing the byte value read, or -1 if the end of the stream is reached.

read

public int read(byte b[], int off, int len)
This method reads up to len bytes from the string buffer input stream into the byte array b beginning off bytes into the array. Note that each byte is actually the lower 8 bits of the corresponding character in the underlying string buffer.
Parameters:
b-the byte array into which the data is read.
off-the starting offset into the array for the data to be written to.
len-the maximum number of bytes to read.
Returns: The actual number of bytes read, or -1 if the end of the stream is reached.

reset

public void reset()
This method resets the read position to the beginning of the string buffer input stream.

skip

public long skip(long n)
This method skips n bytes of data in the string buffer input stream.
Parameters: n-the number of bytes to skip.
Returns: The actual number of bytes skipped.

EOFException

Extends: IOException
This exception class signals that an end-of-file (EOF) has been reached unexpectedly during an input operation. This exception is primarily used by data input streams, which typically expect a binary file in a specific format, in which case an end-of-file is an unusual condition.

FileNotFoundException

Extends: IOException
This exception class signals that a file could not be found.

IOException

Extends: Exception
This exception class signals that some kind of input/output (I/O) exception has occurred.

InterruptedIOException

Extends: IOException
This exception class signals that an input/output (I/O) operation has been interrupted.

UTFDataFormatException

Extends: IOException
This exception class signals that a malformed UTF-8 string has been read in a data input stream.

Main Page
Previous
Next