GigaSpaces XAP 9.7.2 API

com.sun.jini.reliableLog
Class LogInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.sun.jini.reliableLog.LogInputStream
All Implemented Interfaces:
Closeable

public class LogInputStream
extends InputStream

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:
InputStream

Constructor Summary
LogInputStream(InputStream in, int length)
          Creates a log input file with the specified input stream.
 
Method Summary
 int available()
          Returns the number of bytes that can be read without blocking.
 void close()
          Closes the input stream.
protected  void finalize()
          Closes the stream when garbage is collected.
 int read()
          Reads a byte of data.
 int read(byte[] b)
          Reads data into an array of bytes.
 int read(byte[] b, int off, int len)
          Reads data into an array of bytes.
 long skip(long n)
          Skips n bytes of input.
 
Methods inherited from class java.io.InputStream
mark, markSupported, reset
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogInputStream

public LogInputStream(InputStream in,
                      int length)
               throws IOException
Creates a log input file with the specified input stream.

Parameters:
in - the input stream
length - the total number of bytes allowed to be read
Throws:
IOException - If an I/O error has occurred.
Method Detail

read

public int read()
         throws IOException,
                LogException
Reads a byte of data. This method will block if no input is available.

Specified by:
read in class InputStream
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

public int read(byte[] b)
         throws IOException,
                LogException
Reads data into an array of bytes. This method blocks until some input is available.

Overrides:
read in class InputStream
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

public int read(byte[] b,
                int off,
                int len)
         throws IOException,
                LogException
Reads data into an array of bytes. This method blocks until some input is available.

Overrides:
read in class InputStream
Parameters:
b - the buffer into which the data is read
off - the start offset of the data
len - 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

public long skip(long n)
          throws IOException,
                 LogException
Skips n bytes of input.

Overrides:
skip in class InputStream
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:
available in class InputStream
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:
close in interface Closeable
Overrides:
close in class InputStream

finalize

protected void finalize()
                 throws IOException
Closes the stream when garbage is collected.

Overrides:
finalize in class Object
Throws:
IOException

GigaSpaces XAP 9.7.2 API

Copyright © GigaSpaces.