|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.util.Errorable
ewe.io.BasicStreamObject
ewe.io.StreamObject
ewe.io.RandomStreamObject
ewe.io.MemoryFile
This is used for creating a RandomAccessStream from a byte array or from a file on disk.
| Field Summary | |
ByteArray |
data
|
protected int |
mode
|
| Fields inherited from class ewe.io.StreamObject |
napIterations, napTime, READWRITE_CLOSED, READWRITE_ERROR, READWRITE_WOULDBLOCK |
| Fields inherited from class ewe.io.BasicStreamObject |
closed |
| Fields inherited from class ewe.util.Errorable |
error |
| Constructor Summary | |
MemoryFile()
|
|
MemoryFile(byte[] bytes,
int start,
int length,
int mode)
Deprecated. - use new MemoryFile(byte [] bytes,int start,int length,String mode) instead. |
|
MemoryFile(byte[] bytes,
int start,
int length,
String mode)
Create a memory file from an array of bytes. |
|
MemoryFile(ByteArray dataToUse)
This opens it in READ_ONLY mode. |
|
MemoryFile(ByteArray dataToUse,
String mode)
|
|
MemoryFile(File in,
String mode,
boolean useFastStream)
This creates a MemoryFile from an input File. |
|
MemoryFile(Stream is,
String mode)
This creates a MemoryFile from an input stream. |
|
MemoryFile(String path,
int mode)
Deprecated. - use new MemoryFile(Stream is,String mode) instead. |
|
| Method Summary | |
boolean |
canWrite()
Tests if the RandomAccessStream was opened in read-write mode as opposed to read-ony mode. |
static MemoryFile |
createFrom(Stream is,
StringBuffer error)
Deprecated. - use new MemoryFile(Stream is,String mode) instead. |
boolean |
flushStream()
This is non-blocking. |
int |
getFilePosition()
Get the file position. |
int |
getLength()
Returns the length of the file in bytes. |
boolean |
isOpen()
Returns if the stream is open or not. |
int |
nonBlockingRead(byte[] buf,
int start,
int count)
This is the non-blocking read operation. |
int |
nonBlockingWrite(byte[] buf,
int start,
int count)
This is the non-blocking write operation. |
int |
quickRead(byte[] data,
int offset,
int length,
boolean readAll)
This attempts to read using a fast native or direct method. |
void |
quickWrite(byte[] data,
int offset,
int length)
This attempts to write using a fast native or direct access method. |
boolean |
seek(int pos)
Set the file position. |
boolean |
setStreamLength(long length)
Set the length of the RandomAccessStream if possible. |
| Methods inherited from class ewe.io.RandomStreamObject |
getStreamLength, length, nonBlockingRead, nonBlockingWrite, seek, seekPosition, setLength, tell, tellPosition, toRandomStream |
| Methods inherited from class ewe.io.StreamObject |
close, closeStream, doRead, doWrite, flush, nap, nap, read, readAByte, readBytes, readBytes, write, writeAByte, writeBytes, writeBytes |
| Methods inherited from class ewe.io.BasicStreamObject |
getException, getName, read, read, throwIOException, toInputStream, toOutputStream, toStream, write, write |
| Methods inherited from class ewe.util.Errorable |
returnError, returnError, returnError |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Methods inherited from interface ewe.io.BasicStream |
close, closeStream |
| Methods inherited from interface ewe.io.Stream |
flush, read, read, read, readBytes, readBytes, toInputStream, toOutputStream, write, write, write, writeBytes, writeBytes |
| Field Detail |
protected int mode
public ByteArray data
| Constructor Detail |
public MemoryFile()
public MemoryFile(ByteArray dataToUse)
public MemoryFile(ByteArray dataToUse,
String mode)
public MemoryFile(byte[] bytes,
int start,
int length,
int mode)
public MemoryFile(byte[] bytes,
int start,
int length,
String mode)
bytes - start - length - mode -
public MemoryFile(String path,
int mode)
public MemoryFile(File in,
String mode,
boolean useFastStream)
throws IOException
public MemoryFile(Stream is,
String mode)
throws IOException
| Method Detail |
public boolean isOpen()
BasicStream
isOpen in interface BasicStreamisOpen in class StreamObject
public boolean flushStream()
throws IOException
BasicStream
flushStream in interface BasicStreamIOException
public int nonBlockingRead(byte[] buf,
int start,
int count)
BasicStream
nonBlockingRead in interface BasicStreamnonBlockingRead in class StreamObjectbuf - Destination byte array to hold incoming data.start - Starting index in buff for incoming data.count - Maximum number of bytes to read - should never be zero.
public int nonBlockingWrite(byte[] buf,
int start,
int count)
BasicStream
nonBlockingWrite in interface BasicStreamnonBlockingWrite in class StreamObjectbuf - Source byte array holding data to be written.start - Starting index in buff for data to be written.count - Number of bytes to write - should never be zero.
public boolean canWrite()
BasicRandomAccessStream
canWrite in interface BasicRandomAccessStreampublic int getLength()
getLength in interface RandomAccessStreamgetLength in class RandomStreamObjectpublic boolean seek(int pos)
RandomAccessStream
seek in interface RandomAccessStreamseek in class RandomStreamObjectpublic int getFilePosition()
RandomAccessStream
getFilePosition in interface RandomAccessStreamgetFilePosition in class RandomStreamObject
public static MemoryFile createFrom(Stream is,
StringBuffer error)
public boolean setStreamLength(long length)
throws IOException
BasicRandomAccessStreamMake no assumptions about the success of this method. Not all RAS objects will support setStreamLength() or setLength() - not even all Files on all systems will support this. For example, PersonalJava/Java 1.1 does not support this feature and will throw an IOException.
What happens to the file position pointer after this method is called is unpredictable, especially if you are truncating the file. You should ALWAYS reset the file position pointer after calling this method to be where you wish it to be.
setStreamLength in interface BasicRandomAccessStreamsetStreamLength in class RandomStreamObjectIOException
public int quickRead(byte[] data,
int offset,
int length,
boolean readAll)
throws IOException
FastStream
quickRead in interface FastStreamdata - The destination for the data.offset - The index in the destination for the data.length - The number of bytes to read.readAll - if this is true then the method will not return until a full length number of
bytes have been read. If the stream ends before this then an IOException is thrown.
IOException
public void quickWrite(byte[] data,
int offset,
int length)
throws IOException
FastStream
quickWrite in interface FastStreamdata - The source of the data bytes.offset - The index in the source of the data.length - The number of bytes to write.
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||