Class LocalFileRandomAccessContent
- All Implemented Interfaces:
Closeable
,DataInput
,DataOutput
,AutoCloseable
,RandomAccessContent
RandomAccessContent
for local files.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private final RandomAccessFile
private final InputStream
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this random access file stream and releases any system resources associated with the stream.long
Returns the current offset in this file.Get the input stream.long
length()
Returns the length of this file.boolean
byte
readByte()
char
readChar()
double
float
void
readFully
(byte[] b) void
readFully
(byte[] b, int off, int len) int
readInt()
long
readLong()
short
int
int
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
(String s) void
writeChar
(int v) void
writeChars
(String s) void
writeDouble
(double v) void
writeFloat
(float v) void
writeInt
(int v) void
writeLong
(long v) void
writeShort
(int v) void
Methods inherited from class org.apache.commons.vfs2.provider.AbstractRandomAccessContent
readLine
-
Field Details
-
BYTE_VALUE_MASK
private static final int BYTE_VALUE_MASK- See Also:
-
raf
-
rafis
-
-
Constructor Details
-
LocalFileRandomAccessContent
LocalFileRandomAccessContent(File localFile, RandomAccessMode mode) throws FileSystemException - Throws:
FileSystemException
-
-
Method Details
-
close
Description copied from interface:RandomAccessContent
Closes this random access file stream and releases any system resources associated with the stream.A 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.
- Throws:
IOException
- if an I/O error occurs.
-
getFilePointer
Description copied from interface:RandomAccessContent
Returns the current offset in this file.- Returns:
- the offset from the beginning of the file, in bytes, at which the next read or write occurs.
- Throws:
IOException
- if an I/O error occurs.
-
getInputStream
Description copied from interface:RandomAccessContent
Get the input stream.Notice: If you use
RandomAccessContent.seek(long)
you have to re-get the InputStream- Returns:
- the InputStream.
- Throws:
IOException
- if an I/O error occurs.
-
length
Description copied from interface:RandomAccessContent
Returns the length of this file.- Returns:
- the length of this file, measured in bytes.
- Throws:
IOException
- if an I/O error occurs.
-
readBoolean
- Throws:
IOException
-
readByte
- Throws:
IOException
-
readChar
- Throws:
IOException
-
readDouble
- Throws:
IOException
-
readFloat
- Throws:
IOException
-
readFully
- Throws:
IOException
-
readFully
- Throws:
IOException
-
readInt
- Throws:
IOException
-
readLong
- Throws:
IOException
-
readShort
- Throws:
IOException
-
readUnsignedByte
- Throws:
IOException
-
readUnsignedShort
- Throws:
IOException
-
readUTF
- Throws:
IOException
-
seek
Description copied from interface:RandomAccessContent
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.The 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 callingRandomAccessContent.seek(long)
- Parameters:
pos
- the offset position, measured in bytes from the beginning of the file, at which to set the file pointer.- Throws:
IOException
- ifpos
is less than0
or if an I/O error occurs.
-
setLength
Description copied from interface:RandomAccessContent
Sets the length of this content.If the the
newLength
argument is smaller thanRandomAccessContent.length()
, the content is truncated.If the the
newLength
argument is greater thanRandomAccessContent.length()
, the content grows with undefined data.- Parameters:
newLength
- The desired content length- Throws:
IOException
- If an I/O error occurs
-
skipBytes
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classAbstractRandomAccessContent
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classAbstractRandomAccessContent
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classAbstractRandomAccessContent
- Throws:
IOException
-
writeBoolean
- Specified by:
writeBoolean
in interfaceDataOutput
- Overrides:
writeBoolean
in classAbstractRandomAccessContent
- Throws:
IOException
-
writeByte
- Specified by:
writeByte
in interfaceDataOutput
- Overrides:
writeByte
in classAbstractRandomAccessContent
- Throws:
IOException
-
writeBytes
- Specified by:
writeBytes
in interfaceDataOutput
- Overrides:
writeBytes
in classAbstractRandomAccessContent
- Throws:
IOException
-
writeChar
- Specified by:
writeChar
in interfaceDataOutput
- Overrides:
writeChar
in classAbstractRandomAccessContent
- Throws:
IOException
-
writeChars
- Specified by:
writeChars
in interfaceDataOutput
- Overrides:
writeChars
in classAbstractRandomAccessContent
- Throws:
IOException
-
writeDouble
- Specified by:
writeDouble
in interfaceDataOutput
- Overrides:
writeDouble
in classAbstractRandomAccessContent
- Throws:
IOException
-
writeFloat
- Specified by:
writeFloat
in interfaceDataOutput
- Overrides:
writeFloat
in classAbstractRandomAccessContent
- Throws:
IOException
-
writeInt
- Specified by:
writeInt
in interfaceDataOutput
- Overrides:
writeInt
in classAbstractRandomAccessContent
- Throws:
IOException
-
writeLong
- Specified by:
writeLong
in interfaceDataOutput
- Overrides:
writeLong
in classAbstractRandomAccessContent
- Throws:
IOException
-
writeShort
- Specified by:
writeShort
in interfaceDataOutput
- Overrides:
writeShort
in classAbstractRandomAccessContent
- Throws:
IOException
-
writeUTF
- Specified by:
writeUTF
in interfaceDataOutput
- Overrides:
writeUTF
in classAbstractRandomAccessContent
- Throws:
IOException
-