org.entityfs.util.io
Class RandomAccessToInputStreamAdapter

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.entityfs.util.io.RandomAccessToInputStreamAdapter
All Implemented Interfaces:
Closeable

public class RandomAccessToInputStreamAdapter
extends FilterInputStream

This adapter treats a RandomAccess object as an InputStream.

Author:
Karl Gustafsson

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
RandomAccessToInputStreamAdapter(RandomAccess ra)
          Create an adapter between a RandomAccess and an InputStream.
RandomAccessToInputStreamAdapter(RandomAccess ra, boolean closeRandomAccessWhenClosingStream)
          Create an adapter between a RandomAccess and an InputStream.
 
Method Summary
 int available()
           
 void close()
           
 void mark(int readLimit)
          This method does nothing.
 boolean markSupported()
           
 int read()
           
 int read(byte[] barr)
           
 int read(byte[] barr, int off, int len)
           
 void reset()
          This method does nothing.
 long skip(long n)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomAccessToInputStreamAdapter

public RandomAccessToInputStreamAdapter(RandomAccess ra)
Create an adapter between a RandomAccess and an InputStream.

When this adapter is closed, it closes the underlying RandomAccess object. See RandomAccessToInputStreamAdapter(RandomAccess, boolean)

Parameters:
ra - The RandomAccess to adapt.

RandomAccessToInputStreamAdapter

public RandomAccessToInputStreamAdapter(RandomAccess ra,
                                        boolean closeRandomAccessWhenClosingStream)
Create an adapter between a RandomAccess and an InputStream.

Parameters:
ra - The RandomAccess to adapt.
closeRandomAccessWhenClosingStream - Should the RandomAccess be closed when this stream is closed?
Method Detail

available

public int available()
              throws IOException
Overrides:
available in class FilterInputStream
Throws:
IOException

mark

public void mark(int readLimit)
This method does nothing.

Overrides:
mark in class FilterInputStream

reset

public void reset()
This method does nothing.

Overrides:
reset in class FilterInputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class FilterInputStream
Returns:
false.

read

public int read()
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] barr)
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] barr,
                int off,
                int len)
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Overrides:
skip in class FilterInputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class FilterInputStream
Throws:
IOException