|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
com.sun.jini.mercury.LogInputStream
class LogInputStream
This class implements the interface for interacting with input log streams. It extends java.util.InputStream and overrides its methods in order to provide buffered input as well as byte offset tracking, which is useful during recovery situations.
Field Summary | |
---|---|
private byte[] |
buf
byte array buffer to hold read data |
private static int |
BUFSIZE
Holds value of the internal buffer size to allocate |
private int |
count
count of available bytes in the read buffer |
private FileInputStream |
in
Underlying input stream from which bytes are read |
private StreamKey |
key
Associated key for this stream object |
private long |
offset
cumulative index/offset into this stream |
private int |
pos
index/offset into the read buffer for the next set of bytes to read |
Constructor Summary | |
---|---|
LogInputStream(File file,
StreamKey key)
Simple constructor that accepts a File and StreamKey arguments. |
Method Summary | |
---|---|
int |
available()
|
void |
close()
Closes this LogStream object and releases any associated resources. |
Object |
getKey()
Returns the associated key for this LogStream. |
long |
getOffset()
Returns the current "read" offset into this stream object. |
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
private void |
refill()
Refills the internal buffer with any available bytes. |
long |
skip(long n)
|
Methods inherited from class java.io.InputStream |
---|
mark, markSupported, reset |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int BUFSIZE
private byte[] buf
private int count
private int pos
private long offset
private FileInputStream in
private StreamKey key
Constructor Detail |
---|
public LogInputStream(File file, StreamKey key) throws FileNotFoundException
file
- the File to usedkey
- the associated key for this object
IllegalArgumentException
- if either the file or
key arguments are null.
FileNotFoundException
- if the file exists but is a directory
rather than a regular file, does not exist but cannot
be created, or cannot be opened for any other reason.Method Detail |
---|
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b) throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public long skip(long n) throws IOException
skip
in class InputStream
IOException
public int available() throws IOException
available
in class InputStream
IOException
public void close() throws IOException
LogStream
close
in interface LogStream
close
in interface Closeable
close
in class InputStream
IOException
- if an I/O error occured while attempting
to close the LogStream.public long getOffset()
private void refill() throws IOException
IOException
public Object getKey()
LogStream
getKey
in interface LogStream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |