|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Provides an interface that allows read and/or write access to a given resource.
This interface is not needed or used by the user application layer, because it is an SPI interface, which provides for plugging a device into the com.novell.java.io Streams world.
The DataAccessor interface contains all the methods needed to implement InputStream, OutputStream, and RandomAccessFile. Any class that implements this interface can be accessed as a stream or a random access device if supported. It requires the construction of three fully instantiatable classes that operate on a DataAccessor: NInputStream, NOutputStream, and RandomAccess.
NInputStream, NOutputStream, and RandomAccess are the super classes of any corresponding classes that might extend them by supplying any custom data constructors. For example, NFileInputStream extends NInputStream by providing support for mode and data selector parameters that are custom to a file access.
For a device accessor to be able to operate, the device must be open. To facilitate the opening of a device, the DataAccessable interface is implemented.
Field Summary | |
static int |
RANDOM
RANDOM READ/WRITE Stream Type. |
static int |
READ
Read/Input Stream Type. |
static int |
WRITE
Write/Output Stream Type. |
Method Summary | |
int |
available()
Returns the number of bytes left from the current stream position. |
void |
close()
Closes the stream. |
void |
flush()
Flushes all unwritten data. |
long |
length()
Returns the total number of bytes in the stream. |
void |
mark(int limit)
Marks the current stream position, which can be restored by calling reset(). |
boolean |
markSupported()
Determines whether the mark() and reset() methods are supported. |
int |
read()
Reads and returns the next byte in the stream. |
int |
read(byte[] b)
Reads bytes from the stream and fills a byte array with the data read. |
int |
read(byte[] b,
int off,
int len)
Reads bytes from the stream and places the bytes at an offset within a byte array. |
void |
reset()
Resets the stream position to the location saved by mark(). |
long |
seek(long pos)
Moves the stream position to an absolute position in the stream. |
void |
setLength(long len)
Changes the stream length. |
long |
skip(long n)
Moves the stream position forward a specified number of bytes. |
void |
write(byte[] b)
Writes an array of bytes to the stream. |
void |
write(byte[] b,
int off,
int len)
Writes a specified number of bytes from a byte array to the stream, starting at a specified offset in the array. |
void |
write(int b)
Writes one byte to the stream. |
Field Detail |
public static final int READ
(READ = 1)
public static final int WRITE
(WRITE = 2)
public static final int RANDOM
(RANDOM = 3)
Method Detail |
public int available() throws java.io.IOException
public void close() throws java.io.IOException
Any data that has been written to the stream but has not yet been written to actual resource is flushed before the stream is closed.
public void flush() throws java.io.IOException
public boolean markSupported()
If this method returns FALSE, reset() will throw an exception if called.
public void mark(int limit)
limit
- The number of bytes that can be read before
the mark is invalidated.public int read() throws java.io.IOException
public int read(byte[] b) throws java.io.IOException
'b.length' bytes are read and stored in 'b'. If less than 'b.length' bytes are read, the the end-of-file was reached. If no bytes are read and end-of-file was reached, then -1 is returned.
b
- The byte array to which to write.public int read(byte[] b, int off, int len) throws java.io.IOException
'len' bytes are read into 'b' starting at position off. If less than 'len' bytes are read, then the end-of-file was reached. If no bytes are read and end-of-file was reached, -1 is returned.
b
- The byte array to which to write.off
- The array offset where writing should start.len
- The number of bytes to read.public void write(int b) throws java.io.IOException
b
- The byte to write.public void write(byte[] b) throws java.io.IOException
'b.length' bytes are written.
b
- The byte array to write.public void write(byte[] b, int off, int len) throws java.io.IOException
b
- The source array.off
- The array offset from which to start writing.len
- The number of bytes to write.public void reset() throws java.io.IOException
If mark() and reset() are not supported by the stream, an exception is always thrown when reset() is called.
public long skip(long n) throws java.io.IOException
n
- The number of bytes to skip.public long length() throws java.io.IOException
public long seek(long pos) throws java.io.IOException
pos
- The absolute position to which to move.public void setLength(long len) throws java.io.IOException
If the stream is smaller than the desired length, the stream is extended to the desired length using a byte value 0. If the stream is larger than the desired length, the stream is truncated at the desired length.
len
- The desired absolute length of the stream.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |