rebuild.util.io
Class Stream

java.lang.Object
  extended by rebuild.util.io.Stream

public abstract class Stream
extends java.lang.Object

Generic data stream for files and the likes. Functions based off Standard C functions.

Since:
BBX 1.2.0

Field Summary
static int SEEK_CUR
           
static int SEEK_END
           
static int SEEK_SET
           
 
Constructor Summary
Stream()
           
 
Method Summary
abstract  int close()
          Close the stream.
 boolean eof()
          Determine if the end-of-file has been reached.
static Stream fopen(java.lang.String filename, java.lang.String mode)
           
abstract  long getPosition()
           
abstract  long read(byte[] buffer, int offset, int size, int count)
           
 int readByte()
           
abstract  int seek(long offset, int origin)
          Seek through the stream.
 void setPosition(long pos)
           
abstract  long write(byte[] buffer, int offset, int size, int count)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEEK_SET

public static final int SEEK_SET
See Also:
Constant Field Values

SEEK_CUR

public static final int SEEK_CUR
See Also:
Constant Field Values

SEEK_END

public static final int SEEK_END
See Also:
Constant Field Values
Constructor Detail

Stream

public Stream()
Method Detail

getPosition

public abstract long getPosition()

setPosition

public void setPosition(long pos)

seek

public abstract int seek(long offset,
                         int origin)
Seek through the stream.

Parameters:
offset - The offset to seek to, based on origin.
origin - The origin to seek from, either SEEK_SET, SEEK_CUR, or SEEK_END
Returns:
If zero is returned then the seek operation completed successfully, else an error occurred.

read

public abstract long read(byte[] buffer,
                          int offset,
                          int size,
                          int count)
Parameters:
buffer - The location data should be read to.
offset - The offset in the buffer to where data should start being written to.
size - The size of an item to read
count - The number of items of size length to read.
Returns:
Number of items read in

write

public abstract long write(byte[] buffer,
                           int offset,
                           int size,
                           int count)
Parameters:
buffer - The location data should be read from.
offset - The offset in the buffer to where data should start being read from.
size - The size of an item to write
count - The number of items of size length to write.
Returns:
Number of items written

close

public abstract int close()
Close the stream.

Returns:
If zero is returned then the operation completed successfully, else an error occurred.

readByte

public final int readByte()

eof

public final boolean eof()
Determine if the end-of-file has been reached.

Returns:
true if end-of-file has been reached, false if otherwise.

fopen

public static Stream fopen(java.lang.String filename,
                           java.lang.String mode)