Package com.sun.jini.reliableLog
Class LogInputStream
java.lang.Object
java.io.InputStream
com.sun.jini.reliableLog.LogInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
This class extends the functionality of the java.io.InputStream class in order to provide an
input mechanism that can be used by processes that perform logging operations; in particular,
processes that store state in order to provide persistence.
- Author:
- Sun Microsystems, Inc.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLogInputStream(InputStream in, int length) Creates a log input file with the specified input stream. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of bytes that can be read without blocking.voidclose()Closes the input stream.protected voidfinalize()Closes the stream when garbage is collected.intread()Reads a byte of data.intread(byte[] b) Reads data into an array of bytes.intread(byte[] b, int off, int len) Reads data into an array of bytes.longskip(long n) Skips n bytes of input.Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
-
Constructor Details
-
LogInputStream
Creates a log input file with the specified input stream.- Parameters:
in- the input streamlength- the total number of bytes allowed to be read- Throws:
IOException- If an I/O error has occurred.
-
-
Method Details
-
read
Reads a byte of data. This method will block if no input is available.- Specified by:
readin classInputStream- Returns:
- the byte read, or -1 if the end of the stream is reached
- Throws:
LogException- Attempt to read past end of log.IOException- If an I/O error has occurred.
-
read
Reads data into an array of bytes. This method blocks until some input is available.- Overrides:
readin classInputStream- Parameters:
b- the buffer into which the data is read- Returns:
- the actual number of bytes read, -1 is returned when the end of the stream is reached
- Throws:
LogException- Attempt to read past end of log.IOException- If an I/O error has occurred.
-
read
Reads data into an array of bytes. This method blocks until some input is available.- Overrides:
readin classInputStream- Parameters:
b- the buffer into which the data is readoff- the start offset of the datalen- the maximum number of bytes read- Returns:
- the actual number of bytes read, -1 is returned when the end of the stream is reached
- Throws:
LogException- Attempt to read past end of log.IOException- If an I/O error has occurred.
-
skip
Skips n bytes of input.- Overrides:
skipin classInputStream- Parameters:
n- the number of bytes to be skipped- Returns:
- the actual number of bytes skipped
- Throws:
LogException- Attempt to read past end of log.IOException- If an I/O error has occurred.
-
available
public int available()Returns the number of bytes that can be read without blocking.- Overrides:
availablein classInputStream- Returns:
- the number of available bytes, which is initially equal to the file size
-
close
public void close()Closes the input stream. No further input can be read.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream
-
finalize
Closes the stream when garbage is collected.- Overrides:
finalizein classObject- Throws:
IOException
-