edu.mit.jverbnet.util
Class ByteBufferInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by edu.mit.jverbnet.util.ByteBufferInputStream
All Implemented Interfaces:
java.io.Closeable

public class ByteBufferInputStream
extends java.io.InputStream

Adapts a ByteBuffer to an InputStream.

Since:
JVerbnet 1.0.0
Version:
1.2.0
Author:
Mark A. Finlayson

Field Summary
protected  java.nio.ByteBuffer buffer
           
protected  int mark
           
protected  java.io.RandomAccessFile raFile
           
 
Constructor Summary
ByteBufferInputStream(java.nio.ByteBuffer buffer)
          Creates a new input stream that wraps the specified byte buffer.
ByteBufferInputStream(java.io.File file)
          Creates a new input stream that wraps the a byte buffer attached to the specified file.
 
Method Summary
 int available()
           
protected  void checkBuffer()
          Throws an exception if the stream has been closed
 void close()
           
 void mark(int readlimit)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

protected java.nio.ByteBuffer buffer

raFile

protected java.io.RandomAccessFile raFile

mark

protected int mark
Constructor Detail

ByteBufferInputStream

public ByteBufferInputStream(java.nio.ByteBuffer buffer)
Creates a new input stream that wraps the specified byte buffer.

Parameters:
buffer - the byte buffer to be wrapped; may not be null
Throws:
java.lang.NullPointerException - if the specified buffer is null
Since:
JVerbnet 1.0.0

ByteBufferInputStream

public ByteBufferInputStream(java.io.File file)
                      throws java.io.IOException
Creates a new input stream that wraps the a byte buffer attached to the specified file.

Parameters:
file - the file on which the stream should be opened; may not be null
Throws:
java.lang.NullPointerException - if the specified file is null
java.io.IOException
Since:
JVerbnet 1.0.0
Method Detail

checkBuffer

protected void checkBuffer()
                    throws java.io.IOException
Throws an exception if the stream has been closed

Throws:
java.io.IOException - if the stream has been closed
Since:
JVerbnet 1.0.0

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException

mark

public void mark(int readlimit)
Overrides:
mark in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.InputStream


Copyright © 2012 ${project.organization.name}. All Rights Reserved.