|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.blinkenbyte.io.ReadWriteFile
public class ReadWriteFile
Class to present a file as a ReadWriteDevice. Essentially an extension of RandomAccessFile
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.blinkenbyte.io.ReadWriteDevice |
|---|
ReadWriteDevice.RWDInputStream, ReadWriteDevice.RWDOutputStream |
| Field Summary | |
|---|---|
protected boolean |
isClosed
Flag indicating whether this ReadWriteFile has been closed. |
protected long |
markPtr
The current mark. |
protected java.io.RandomAccessFile |
raf
The RandomAccessFile being wrapped |
| Constructor Summary | |
|---|---|
ReadWriteFile(java.io.File file,
java.lang.String mode)
Constructs a new ReadWriteFile using the specified File and mode. |
|
ReadWriteFile(java.io.RandomAccessFile _raf)
Constructs a new ReadWriteFile around the specified RandomAccessFile |
|
ReadWriteFile(java.lang.String filename,
java.lang.String mode)
Constructs a new ReadWriteFile using the specified filename and mode. |
|
| Method Summary | |
|---|---|
int |
available()
Returns 0. |
void |
close()
Closes this object and the underlying RandomAccessFile. |
void |
flush()
Flushes the underlying RandomAccessFile. |
ReadWriteDevice.RWDInputStream |
getInputStream()
Returns a new RWDInputStream wrapped around this object. |
ReadWriteDevice.RWDOutputStream |
getOutputStream()
Returns a new RWDOutputStream wrapped around this object. |
long |
getPointer()
Returns the current file pointer. |
long |
length()
Returns the length of the underlying file. |
void |
mark(long markLimit)
Sets the mark with the specified mark limit. |
boolean |
markSupported()
Returns true. |
int |
read()
Reads a byte from the underlying ReadWriteDevice. |
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 last mark. |
void |
seek(long newPointer)
Seeks the underlying file to the specified position. |
long |
skip(long n)
Advances the file pointer by the specified number of bytes. |
protected void |
throwIfClosed()
Convenience method to throw an exception if this object has already been closed. |
void |
write(byte[] b)
Writes b.length bytes from array b to the stream. |
void |
write(byte[] b,
int offset,
int len)
Writes len bytes from array b at offset b[offset] to the stream. |
void |
write(int b)
Writes a single byte to the stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.io.RandomAccessFile raf
protected long markPtr
protected boolean isClosed
| Constructor Detail |
|---|
public ReadWriteFile(java.io.RandomAccessFile _raf)
throws java.io.IOException
java.io.IOException
public ReadWriteFile(java.io.File file,
java.lang.String mode)
throws java.io.FileNotFoundException
RandomAccessFile.
java.io.FileNotFoundException
public ReadWriteFile(java.lang.String filename,
java.lang.String mode)
throws java.io.FileNotFoundException
RandomAccessFile.
java.io.FileNotFoundException| Method Detail |
|---|
public int available()
throws java.io.IOException
available in interface ReadWriteDevicejava.io.IOException
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface ReadWriteDevicejava.io.IOException
public void flush()
throws java.io.IOException
flush in interface ReadWriteDevicejava.io.IOException
protected void throwIfClosed()
throws java.io.IOException
java.io.IOException
public long length()
throws java.io.IOException
length in interface ReadWriteDevicejava.io.IOException
public long getPointer()
throws java.io.IOException
getPointer in interface ReadWriteDevicejava.io.IOException
public void seek(long newPointer)
throws java.io.IOException
seek in interface ReadWriteDevicejava.io.IOException
public long skip(long n)
throws java.io.IOException
skip in interface ReadWriteDevicejava.io.IOException
public int read()
throws java.io.IOException
read in interface ReadWriteDevicejava.io.IOException
public int read(byte[] b)
throws java.io.IOException
read in interface ReadWriteDevicejava.io.IOException
public int read(byte[] b,
int offset,
int len)
throws java.io.IOException
read in interface ReadWriteDevicejava.io.IOException
public void write(int b)
throws java.io.IOException
write in interface ReadWriteDevicejava.io.IOException
public void write(byte[] b)
throws java.io.IOException
write in interface ReadWriteDevicejava.io.IOException
public void write(byte[] b,
int offset,
int len)
throws java.io.IOException
write in interface ReadWriteDevicejava.io.IOException
public void mark(long markLimit)
throws java.io.IOException
mark in interface ReadWriteDevicejava.io.IOExceptionpublic boolean markSupported()
markSupported in interface ReadWriteDevice
public void reset()
throws java.io.IOException
reset in interface ReadWriteDevicejava.io.IOExceptionpublic ReadWriteDevice.RWDInputStream getInputStream()
getInputStream in interface ReadWriteDevicepublic ReadWriteDevice.RWDOutputStream getOutputStream()
getOutputStream in interface ReadWriteDevice
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||