|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.InputStream
com.mucommander.io.RandomAccessInputStream
public abstract class RandomAccessInputStream
RandomAccessInputStream is an InputStream with random access.
The following java.io.InputStream methods are overridden to provide an improved implementation:
BufferedInputStream or any wrapper InputStream class that uses a read buffer
CANNOT be used with a RandomAccessInputStream if the RandomAccess.seek(long) method is to be used. Doing so
would corrupt the read buffer and yield to data inconsistencies.
| Constructor Summary | |
|---|---|
RandomAccessInputStream()
Creates a new RandomAccessInputStream. |
|
| Method Summary | |
|---|---|
int |
available()
Return the number of bytes that are available for reading, that is: RandomAccess.getLength() - RandomAccess.getOffset() - 1. |
abstract void |
close()
Closes this stream and releases any system resources associated with the stream. |
void |
mark(int readLimit)
Overrides InputStream.mark() to provide a working implementation of the method. |
boolean |
markSupported()
Always returns true: mark(int) and reset() methods are supported. |
abstract int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from this file into an array of bytes. |
void |
readFully(byte[] b)
Reads b.length bytes from this file into the byte array, starting at the current file pointer. |
void |
readFully(byte[] b,
int off,
int len)
Reads exactly len bytes from this file into the byte array, starting at the current file pointer. |
void |
reset()
Overrides InputStream.mark() to provide a working implementation of the method. |
long |
skip(long n)
Skips (up to) the specified number of bytes and returns the number of bytes effectively skipped. |
| Methods inherited from class java.io.InputStream |
|---|
read, read |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.mucommander.io.RandomAccess |
|---|
getLength, getOffset, seek |
| Constructor Detail |
|---|
public RandomAccessInputStream()
| Method Detail |
|---|
public void readFully(byte[] b)
throws java.io.IOException
b.length bytes from this file into the byte array, starting at the current file pointer.
This method reads repeatedly from the file until the requested number of bytes are read. This method blocks until
the requested number of bytes are read, the end of the stream is detected, or an exception is thrown.
b - the buffer into which the data is read.
java.io.EOFException - if this file reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.
public void readFully(byte[] b,
int off,
int len)
throws java.io.IOException
len bytes from this file into the byte array, starting at the current file pointer.
This method reads repeatedly from the file until the requested number of bytes are read. This method blocks until
the requested number of bytes are read, the end of the stream is detected, or an exception is thrown.
b - the buffer into which the data is read.off - the start offset of the data.len - the number of bytes to read.
java.io.EOFException - if this file reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.
public long skip(long n)
throws java.io.IOException
RandomAccess.getOffset()
plus the number of bytes to skip doesn't exceed the length of this stream as returned by RandomAccess.getLength().
If it does, all the remaining bytes will be skipped so that the offset of this stream will be positionned to
RandomAccess.getLength().
Returns -1 if the offset is already positionned to the end of the stream when this method is called.
skip in class java.io.InputStreamn - number of bytes to skip
java.io.IOException - if something went wrong
public int available()
throws java.io.IOException
RandomAccess.getLength() - RandomAccess.getOffset() - 1.
Since InputStream.available() returns an int and this method overrides it, a maximum of
Integer.MAX_VALUE can be returned, even if this stream has more bytes available.
available in class java.io.InputStreamjava.io.IOException - if something went wrongpublic void mark(int readLimit)
InputStream.mark() to provide a working implementation of the method. The given readLimit
is simply ignored, the stream can be repositionned using reset() with no limit on the number of bytes
read after mark() has been called.
mark in class java.io.InputStreamreadLimit - this parameter has no effect and is simply ignored
public void reset()
throws java.io.IOException
InputStream.mark() to provide a working implementation of the method.
reset in class java.io.InputStreamjava.io.IOException - if something went wrongpublic boolean markSupported()
true: mark(int) and reset() methods are supported.
markSupported in class java.io.InputStream
public abstract int read(byte[] b,
int off,
int len)
throws java.io.IOException
len bytes of data from this file into an array of bytes. This method blocks until at
least one byte of input is available.
read in class java.io.InputStreamb - the buffer into which the data is readoff - the start offset of the datalen - the maximum number of bytes read
java.io.IOException - if an I/O error occurs
public abstract void close()
throws java.io.IOException
close in interface RandomAccessclose in interface java.io.Closeableclose in class java.io.InputStreamjava.io.IOException - if an I/O error occurs.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard