|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
com.sun.jini.mercury.LogOutputStream
class LogOutputStream
This class implements the interface for interacting with output log streams. It extends java.util.OutputStream and overrides its methods in order to provide buffered output as well as byte offset tracking, which is useful during recovery situations. The additional methods drain and sync allow for the flushing of any buffered data and synchronizing data buffers with the underlying device, respectively.
Field Summary | |
---|---|
private byte[] |
buf
byte array buffer for written data |
private static int |
BUFSIZE
Holds value of the internal buffer size to allocate |
private StreamKey |
key
Associated key for this stream object |
private long |
offset
cumulative index/offset into this stream |
private FileOutputStream |
out
Underlying output stream from which bytes are written |
private int |
pos
index/offset into the internal write buffer |
Constructor Summary | |
---|---|
LogOutputStream(File file,
StreamKey key,
boolean append)
Simple constructor that accepts a File, StreamKey and boolean arguments. |
Method Summary | |
---|---|
void |
close()
Closes this LogStream object and releases any associated resources. |
(package private) void |
drain()
Writes any unwritten bytes to the underlying output stream. |
void |
flush()
|
Object |
getKey()
Returns the associated key for this LogStream. |
(package private) long |
getOffset()
Returns the current "write" offset into this stream object. |
(package private) void |
sync()
Synchronizes system buffers with underlying device. |
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
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 pos
private long offset
private FileOutputStream out
private StreamKey key
Constructor Detail |
---|
public LogOutputStream(File file, StreamKey key, boolean append) throws FileNotFoundException
file
- the File to usedkey
- the associated key for this objectappend
- determines whether or not to append to the
underlying stream
IllegalArgumentException
- if either the file or
key argument is 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 reasonMethod Detail |
---|
public void write(int b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public void close() throws IOException
LogStream
close
in interface LogStream
close
in interface Closeable
close
in class OutputStream
IOException
- if an I/O error occured while attempting
to close the LogStream.long getOffset()
void sync() throws IOException, SyncFailedException
IOException
- if an I/O error occurs
SyncFailedException
- if the buffers cannot be guaranteed to
have synchronized with physical mediavoid drain() throws IOException
IOException
- if an I/O error occurspublic Object getKey()
LogStream
getKey
in interface LogStream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |