com.jfimagine.utils.io
Interface JFReader

All Known Implementing Classes:
JFBinaryReader

public interface JFReader

JFReader is a reader interface to handle JFDraw files reading.

Version:
$Revision: 1.1 $
Author:
CookieMaker

Method Summary
 int read(byte[] b, int off, int len)
          Reads up to len bytes of data from the contained input stream into an array of bytes.
 boolean readBoolean()
          Reads one input byte and returns true if that byte is nonzero, false if that byte is zero.
 byte readByte()
          Reads and returns one input byte.
 char readChar()
          Reads an input char and returns the char value.
 double readDouble()
          Reads eight input bytes and returns a double value.
 float readFloat()
          Reads four input bytes and returns a float value.
 int readInt()
          Reads four input bytes and returns an int value.
 long readLong()
          Reads eight input bytes and returns a long value.
 short readShort()
          Reads two input bytes and returns a short value.
 int readUnsignedByte()
          Reads one input byte, zero-extends it to type int, and returns the result, which is therefore in the range 0 through 255.
 int readUnsignedShort()
          Reads two input bytes and returns an int value in the range 0 through 65535.
 java.lang.String readUTF()
          Reads in a string that has been encoded using a modified UTF-8 format.
 int skipBytes(int n)
          Makes an attempt to skip over n bytes of data from the input stream, discarding the skipped bytes.
 

Method Detail

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads up to len bytes of data from the contained input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read, possibly zero. The number of bytes actually read is returned as an integer.

Parameters:
b - the buffer into which the data is read.
off - the start offset of the data.
len - the maximum number of bytes read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException - if an I/O error occurs.

skipBytes

public int skipBytes(int n)
              throws java.io.IOException
Makes an attempt to skip over n bytes of data from the input stream, discarding the skipped bytes. The actual number of bytes skipped is returned.

Parameters:
n - the number of bytes to be skipped.
Returns:
the number of bytes actually skipped.
Throws:
java.io.IOException - if an I/O error occurs.

readBoolean

public boolean readBoolean()
                    throws java.io.IOException
Reads one input byte and returns true if that byte is nonzero, false if that byte is zero. This method is suitable for reading the byte written by the writeBoolean method in JFWriter.

Returns:
the boolean value read.
Throws:
EOFException - if this stream reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.

readByte

public byte readByte()
              throws java.io.IOException
Reads and returns one input byte. The byte is treated as a signed value in This method is suitable for reading the byte written by the writeByte method in JFWriter.

Returns:
the 8-bit value read.
Throws:
EOFException - if this stream reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.

readUnsignedByte

public int readUnsignedByte()
                     throws java.io.IOException
Reads one input byte, zero-extends it to type int, and returns the result, which is therefore in the range 0 through 255. This method is suitable for reading the byte written by the writeByte method in JFWriter.

Returns:
the unsigned 8-bit value read.
Throws:
EOFException - if this stream reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.

readShort

public short readShort()
                throws java.io.IOException
Reads two input bytes and returns a short value. This method is suitable for reading the bytes written by the writeShort method in JFWriter.

Returns:
the 16-bit value read.
Throws:
EOFException - if this stream reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.

readUnsignedShort

public int readUnsignedShort()
                      throws java.io.IOException
Reads two input bytes and returns an int value in the range 0 through 65535. This method is suitable for reading the bytes written by the writeShort method in JFWriter.

Returns:
the unsigned 16-bit value read.
Throws:
EOFException - if this stream reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.

readChar

public char readChar()
              throws java.io.IOException
Reads an input char and returns the char value. This method is suitable for reading bytes written by the writeChar method in JFWriter.

Returns:
the Unicode char read.
Throws:
EOFException - if this stream reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.

readInt

public int readInt()
            throws java.io.IOException
Reads four input bytes and returns an int value. This method is suitable for reading bytes written by the writeInt method in JFWriter.

Returns:
the int value read.
Throws:
EOFException - if this stream reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.

readLong

public long readLong()
              throws java.io.IOException
Reads eight input bytes and returns a long value. This method is suitable for reading bytes written by the writeLong method in JFWriter.

Returns:
the long value read.
Throws:
EOFException - if this stream reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.

readFloat

public float readFloat()
                throws java.io.IOException
Reads four input bytes and returns a float value. This method is suitable for reading bytes written by the writeFloat method in JFWriter.

Returns:
the float value read.
Throws:
EOFException - if this stream reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.

readDouble

public double readDouble()
                  throws java.io.IOException
Reads eight input bytes and returns a double value. This method is suitable for reading bytes written by the writeDouble method in JFWriter.

Returns:
the double value read.
Throws:
EOFException - if this stream reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.

readUTF

public java.lang.String readUTF()
                         throws java.io.IOException
Reads in a string that has been encoded using a modified UTF-8 format.

The writeUTF method in JFWriter may be used to write data that is suitable for reading by this method.

Returns:
a Unicode string.
Throws:
EOFException - if this stream reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.
UTFDataFormatException - if the bytes do not represent a valid UTF-8 encoding of a string.


Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All Rights Reserved.