public class NativeRandomStream extends RandomStream
READ_ONLY, READ_WRITE| Modifier and Type | Method and Description |
|---|---|
void |
close()
This method closes the stream.
|
protected void |
finalize()
This method (when overriden), will be called when the VM determines that the Object can be
garbage collected.
|
void |
flush()
This method forces any data that may have been buffered to be written
to the underlying output device.
|
long |
getLength()
Return the full length of the Stream.
|
long |
getPosition()
Return the current read/write stream pointer.
|
int |
hashCode()
Returns a hashCode for the object.
|
int |
read()
This method reads an unsigned byte from the input stream and returns it
as an int in the range of 0-255.
|
int |
read(byte[] data,
int offset,
int count)
This method read bytes from a stream and stores them into a
caller supplied buffer.
|
void |
setLength(long length)
Attempt to set the length of the stream if this is supported.
|
void |
setPosition(long newPosition)
Set the Stream position.
|
long |
skip(long n)
This method skips the specified number of bytes in the stream.
|
protected void |
throwCantWrite()
Throw an IOException indicating that you cannot write to this RandomStream.
|
static RandomStream |
toRandomStream(int nativeStream,
String mode) |
void |
write(byte[] data,
int offset,
int count)
This method writes
len bytes from the specified array
b starting at index off into the array. |
void |
write(int b)
This method writes a single byte to the output stream.
|
canSetLength, isOpenForWriting, isReadWrite, mark, markSupported, reset, setMode, toOutputStream, validateMode, writeavailable, readpublic static RandomStream toRandomStream(int nativeStream, String mode)
public int hashCode()
ObjecthashCode in class InputStreampublic int read()
throws IOException
InputStreamThis method will block until the byte can be read.
read in class InputStreamIOException - If an error occurspublic int read(byte[] data,
int offset,
int count)
throws IOException
InputStreamoff into the buffer and attempts to read
len bytes. This method can return before reading the
number of bytes requested. The actual number of bytes read is
returned as an int. A -1 is returned to indicate the end of the
stream.
This method will block until some data can be read.
This method operates by calling the single byte read() method
in a loop until the desired number of bytes are read. The read loop
stops short if the end of the stream is encountered or if an IOException
is encountered on any read operation except the first. If the first
attempt to read a bytes fails, the IOException is allowed to propagate
upward. And subsequent IOException is caught and treated identically
to an end of stream condition. Subclasses can (and should if possible)
override this method to provide a more efficient implementation.
read in class InputStreamdata - The array into which the bytes read should be storedoffset - The offset into the array to start storing bytescount - The requested number of bytes to readIOException - If an error occurs.public void close()
throws IOException
InputStreamIOException
This method does nothing in this class, but subclasses may override this method in order to provide additional functionality.
close in class InputStreamIOException - If an error occurs, which can only happen
in a subclasspublic long skip(long n)
throws IOException
InputStreamThis method reads and discards bytes into a byte array until the specified number of bytes were skipped or until either the end of stream is reached or a read attempt returns a short count. Subclasses can override this metho to provide a more efficient implementation where one exists.
skip in class RandomStreamn - The requested number of bytes to skipIOException - If an error occursprotected void finalize()
ObjectThe finalize() method of a Class is only called if it overrides finalize() - the finalize() method java.lang.Object is never called by the Eve VM.
finalize in class InputStreampublic long getLength()
throws IOException
RandomStreamgetLength in class RandomStreamIOException - if an IO error occured.public void setLength(long length)
throws IOException
RandomStreamsetLength in class RandomStreamIOException - if the length cannot be set or if there was an error.public long getPosition()
throws IOException
RandomStreamgetPosition in class RandomStreamIOException - on error.public void setPosition(long newPosition)
throws IOException
RandomStreamsetPosition in class RandomStreamnewPosition - the new position to set.IOException - on error.public void write(int b)
throws IOException
RandomStreamint passed as the argument.
Subclasses must provide an implementation of this method.
write in class RandomStreamb - The byte to be written to the output stream, passed as
the low eight bits of an intIOException - If an error occurspublic void write(byte[] data,
int offset,
int count)
throws IOException,
NullPointerException,
IndexOutOfBoundsException
RandomStreamlen bytes from the specified array
b starting at index off into the array.
This method in this class calls the single byte write()
method in a loop until all bytes have been written. Subclasses should
override this method if possible in order to provide a more efficent
implementation.
write in class RandomStreamdata - The array of bytes to write fromoffset - The index into the array to start writing fromcount - The number of bytes to writeIOException - If an error occursNullPointerExceptionIndexOutOfBoundsExceptionpublic void flush()
throws IOException
RandomStreamThis method in this class does nothing.
flush in class RandomStreamIOException - If an error occursprotected void throwCantWrite()
throws IOException
RandomStreamthrowCantWrite in class RandomStreamIOException - always thrown.