class LocalFileRandomAccessContent extends AbstractRandomAccessContent
RandomAccessContent for local files.| Modifier and Type | Field and Description |
|---|---|
private java.io.RandomAccessFile |
raf |
private java.io.InputStream |
rafis |
| Constructor and Description |
|---|
LocalFileRandomAccessContent(java.io.File localFile,
RandomAccessMode mode) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this random access file stream and releases any system resources associated with the stream.
|
long |
getFilePointer()
Returns the current offset in this file.
|
java.io.InputStream |
getInputStream()
Get the input stream.
|
long |
length()
Returns the length of this file.
|
boolean |
readBoolean() |
byte |
readByte() |
char |
readChar() |
double |
readDouble() |
float |
readFloat() |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
int |
readInt() |
long |
readLong() |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
java.lang.String |
readUTF() |
void |
seek(long pos)
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.
|
void |
setLength(long newLength)
Sets the length of this content.
|
int |
skipBytes(int n) |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
void |
writeBoolean(boolean v) |
void |
writeByte(int v) |
void |
writeBytes(java.lang.String s) |
void |
writeChar(int v) |
void |
writeChars(java.lang.String s) |
void |
writeDouble(double v) |
void |
writeFloat(float v) |
void |
writeInt(int v) |
void |
writeLong(long v) |
void |
writeShort(int v) |
void |
writeUTF(java.lang.String str) |
readLineprivate final java.io.RandomAccessFile raf
private final java.io.InputStream rafis
LocalFileRandomAccessContent(java.io.File localFile,
RandomAccessMode mode)
throws FileSystemException
FileSystemExceptionpublic long getFilePointer()
throws java.io.IOException
RandomAccessContentjava.io.IOException - if an I/O error occurs.public void seek(long pos)
throws java.io.IOException
RandomAccessContentThe offset may be set beyond the end of the file. Setting the offset beyond the end of the file does not change the file length. The file length will change only by writing after the offset has been set beyond the end of the file.
Notice: If you use RandomAccessContent.getInputStream() you have to re-get the InputStream after calling
RandomAccessContent.seek(long)
pos - the offset position, measured in bytes from the beginning of the file, at which to set the file
pointer.java.io.IOException - if pos is less than 0 or if an I/O error occurs.public long length()
throws java.io.IOException
RandomAccessContentjava.io.IOException - if an I/O error occurs.public void close()
throws java.io.IOException
RandomAccessContentA closed random access file cannot perform input or output operations and cannot be reopened.
If this file has an associated channel then the channel is closed as well.
java.io.IOException - if an I/O error occurs.public byte readByte()
throws java.io.IOException
java.io.IOExceptionpublic char readChar()
throws java.io.IOException
java.io.IOExceptionpublic double readDouble()
throws java.io.IOException
java.io.IOExceptionpublic float readFloat()
throws java.io.IOException
java.io.IOExceptionpublic int readInt()
throws java.io.IOException
java.io.IOExceptionpublic int readUnsignedByte()
throws java.io.IOException
java.io.IOExceptionpublic int readUnsignedShort()
throws java.io.IOException
java.io.IOExceptionpublic long readLong()
throws java.io.IOException
java.io.IOExceptionpublic short readShort()
throws java.io.IOException
java.io.IOExceptionpublic boolean readBoolean()
throws java.io.IOException
java.io.IOExceptionpublic int skipBytes(int n)
throws java.io.IOException
java.io.IOExceptionpublic void readFully(byte[] b)
throws java.io.IOException
java.io.IOExceptionpublic void readFully(byte[] b,
int off,
int len)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String readUTF()
throws java.io.IOException
java.io.IOExceptionpublic void writeDouble(double v)
throws java.io.IOException
writeDouble in interface java.io.DataOutputwriteDouble in class AbstractRandomAccessContentjava.io.IOExceptionpublic void writeFloat(float v)
throws java.io.IOException
writeFloat in interface java.io.DataOutputwriteFloat in class AbstractRandomAccessContentjava.io.IOExceptionpublic void write(int b)
throws java.io.IOException
write in interface java.io.DataOutputwrite in class AbstractRandomAccessContentjava.io.IOExceptionpublic void writeByte(int v)
throws java.io.IOException
writeByte in interface java.io.DataOutputwriteByte in class AbstractRandomAccessContentjava.io.IOExceptionpublic void writeChar(int v)
throws java.io.IOException
writeChar in interface java.io.DataOutputwriteChar in class AbstractRandomAccessContentjava.io.IOExceptionpublic void writeInt(int v)
throws java.io.IOException
writeInt in interface java.io.DataOutputwriteInt in class AbstractRandomAccessContentjava.io.IOExceptionpublic void writeShort(int v)
throws java.io.IOException
writeShort in interface java.io.DataOutputwriteShort in class AbstractRandomAccessContentjava.io.IOExceptionpublic void writeLong(long v)
throws java.io.IOException
writeLong in interface java.io.DataOutputwriteLong in class AbstractRandomAccessContentjava.io.IOExceptionpublic void writeBoolean(boolean v)
throws java.io.IOException
writeBoolean in interface java.io.DataOutputwriteBoolean in class AbstractRandomAccessContentjava.io.IOExceptionpublic void write(byte[] b)
throws java.io.IOException
write in interface java.io.DataOutputwrite in class AbstractRandomAccessContentjava.io.IOExceptionpublic void write(byte[] b,
int off,
int len)
throws java.io.IOException
write in interface java.io.DataOutputwrite in class AbstractRandomAccessContentjava.io.IOExceptionpublic void writeBytes(java.lang.String s)
throws java.io.IOException
writeBytes in interface java.io.DataOutputwriteBytes in class AbstractRandomAccessContentjava.io.IOExceptionpublic void writeChars(java.lang.String s)
throws java.io.IOException
writeChars in interface java.io.DataOutputwriteChars in class AbstractRandomAccessContentjava.io.IOExceptionpublic void writeUTF(java.lang.String str)
throws java.io.IOException
writeUTF in interface java.io.DataOutputwriteUTF in class AbstractRandomAccessContentjava.io.IOExceptionpublic java.io.InputStream getInputStream()
throws java.io.IOException
RandomAccessContent
Notice: If you use RandomAccessContent.seek(long) you have to re-get the InputStream
java.io.IOException - if an I/O error occurs.public void setLength(long newLength)
throws java.io.IOException
RandomAccessContent
If the the newLength argument is smaller than RandomAccessContent.length(), the content is truncated.
If the the newLength argument is greater than RandomAccessContent.length(), the content grows with undefined data.
newLength - The desired content lengthjava.io.IOException - If an I/O error occurs