org.blinkenbyte.io
Interface ReadWriteDevice

All Superinterfaces:
java.io.Closeable
All Known Implementing Classes:
ReadWriteByteArray, ReadWriteFile

public interface ReadWriteDevice
extends java.io.Closeable

Interface for defining stream oriented read/write devices.


Nested Class Summary
static class ReadWriteDevice.RWDInputStream
          Implementation of an InputStream wrapped around a ReadWriteDevice.
static class ReadWriteDevice.RWDOutputStream
          Implementation of an OutputStream wrapped around a ReadWriteDevice.
 
Method Summary
 int available()
          Returns the number of bytes between the current pointer and end-of-stream.
 void close()
          Closes the device.
 void flush()
          Flushes the device.
 java.io.InputStream getInputStream()
          Return an InputStream for reading from this device.
 java.io.OutputStream getOutputStream()
          Return an OututStream for writing to this device.
 long getPointer()
          Returns the current pointer for this device.
 long length()
          Returns the total length in bytes of this device.
 void mark(long markLimit)
          Sets the mark with the specified limit.
 boolean markSupported()
          Returns whether mark is supported.
 int read()
          Reads and returns a single byte.
 int read(byte[] b)
          Reads up to b.length bytes from the device into array b.
 int read(byte[] b, int offset, int len)
          Reads up to len bytes from the device into array b at b[offset].
 void reset()
          Resets the pointer to the mark position.
 void seek(long newPointer)
          Seeks the pointer to the specified offset.
 long skip(long amtToSkip)
          Advances the pointer by the specified number of bytes
 void write(byte[] b)
          Writes b.length bytes from array b to the device.
 void write(byte[] b, int offset, int len)
          Writes len bytes from array b starting at b[offset] to the device.
 void write(int b)
          Writes a single byte to the device.
 

Method Detail

close

void close()
           throws java.io.IOException
Closes the device.

Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException

flush

void flush()
           throws java.io.IOException
Flushes the device.

Throws:
java.io.IOException

available

int available()
              throws java.io.IOException
Returns the number of bytes between the current pointer and end-of-stream.

Throws:
java.io.IOException

length

long length()
            throws java.io.IOException
Returns the total length in bytes of this device.

Throws:
java.io.IOException

getPointer

long getPointer()
                throws java.io.IOException
Returns the current pointer for this device.

Throws:
java.io.IOException

seek

void seek(long newPointer)
          throws java.io.IOException
Seeks the pointer to the specified offset.

Throws:
java.io.IOException

skip

long skip(long amtToSkip)
          throws java.io.IOException
Advances the pointer by the specified number of bytes

Throws:
java.io.IOException

read

int read()
         throws java.io.IOException
Reads and returns a single byte. Returns -1 if end-of-stream.

Throws:
java.io.IOException

read

int read(byte[] b)
         throws java.io.IOException
Reads up to b.length bytes from the device into array b. Returns the number of bytes read, -1 if currently at end-of-stream.

Throws:
java.io.IOException

read

int read(byte[] b,
         int offset,
         int len)
         throws java.io.IOException
Reads up to len bytes from the device into array b at b[offset]. Returns the number of bytes read, -1 if currently at end-of-stream.

Throws:
java.io.IOException

write

void write(int b)
           throws java.io.IOException
Writes a single byte to the device.

Throws:
java.io.IOException

write

void write(byte[] b)
           throws java.io.IOException
Writes b.length bytes from array b to the device.

Throws:
java.io.IOException

write

void write(byte[] b,
           int offset,
           int len)
           throws java.io.IOException
Writes len bytes from array b starting at b[offset] to the device.

Throws:
java.io.IOException

mark

void mark(long markLimit)
          throws java.io.IOException
Sets the mark with the specified limit.

Throws:
java.io.IOException

markSupported

boolean markSupported()
Returns whether mark is supported.


reset

void reset()
           throws java.io.IOException
Resets the pointer to the mark position.

Throws:
java.io.IOException

getInputStream

java.io.InputStream getInputStream()
Return an InputStream for reading from this device.


getOutputStream

java.io.OutputStream getOutputStream()
Return an OututStream for writing to this device.