Class LocalFileRandomAccessContent
- All Implemented Interfaces:
Closeable,DataInput,DataOutput,AutoCloseable,RandomAccessContent
RandomAccessContent for local files.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final RandomAccessFileprivate final InputStream -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this random access file stream and releases any system resources associated with the stream.longReturns the current offset in this file.Get the input stream.longlength()Returns the length of this file.booleanbytereadByte()charreadChar()doublefloatvoidreadFully(byte[] b) voidreadFully(byte[] b, int off, int len) intreadInt()longreadLong()shortintintreadUTF()voidseek(long pos) Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.voidsetLength(long newLength) Sets the length of this content.intskipBytes(int n) voidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(int b) voidwriteBoolean(boolean v) voidwriteByte(int v) voidwriteBytes(String s) voidwriteChar(int v) voidwriteChars(String s) voidwriteDouble(double v) voidwriteFloat(float v) voidwriteInt(int v) voidwriteLong(long v) voidwriteShort(int v) voidMethods 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:RandomAccessContentCloses 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:RandomAccessContentReturns 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:RandomAccessContentGet 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:RandomAccessContentReturns 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:RandomAccessContentSets 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- ifposis less than0or if an I/O error occurs.
-
setLength
Description copied from interface:RandomAccessContentSets the length of this content.If the the
newLengthargument is smaller thanRandomAccessContent.length(), the content is truncated.If the the
newLengthargument 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:
writein interfaceDataOutput- Overrides:
writein classAbstractRandomAccessContent- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Overrides:
writein classAbstractRandomAccessContent- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Overrides:
writein classAbstractRandomAccessContent- Throws:
IOException
-
writeBoolean
- Specified by:
writeBooleanin interfaceDataOutput- Overrides:
writeBooleanin classAbstractRandomAccessContent- Throws:
IOException
-
writeByte
- Specified by:
writeBytein interfaceDataOutput- Overrides:
writeBytein classAbstractRandomAccessContent- Throws:
IOException
-
writeBytes
- Specified by:
writeBytesin interfaceDataOutput- Overrides:
writeBytesin classAbstractRandomAccessContent- Throws:
IOException
-
writeChar
- Specified by:
writeCharin interfaceDataOutput- Overrides:
writeCharin classAbstractRandomAccessContent- Throws:
IOException
-
writeChars
- Specified by:
writeCharsin interfaceDataOutput- Overrides:
writeCharsin classAbstractRandomAccessContent- Throws:
IOException
-
writeDouble
- Specified by:
writeDoublein interfaceDataOutput- Overrides:
writeDoublein classAbstractRandomAccessContent- Throws:
IOException
-
writeFloat
- Specified by:
writeFloatin interfaceDataOutput- Overrides:
writeFloatin classAbstractRandomAccessContent- Throws:
IOException
-
writeInt
- Specified by:
writeIntin interfaceDataOutput- Overrides:
writeIntin classAbstractRandomAccessContent- Throws:
IOException
-
writeLong
- Specified by:
writeLongin interfaceDataOutput- Overrides:
writeLongin classAbstractRandomAccessContent- Throws:
IOException
-
writeShort
- Specified by:
writeShortin interfaceDataOutput- Overrides:
writeShortin classAbstractRandomAccessContent- Throws:
IOException
-
writeUTF
- Specified by:
writeUTFin interfaceDataOutput- Overrides:
writeUTFin classAbstractRandomAccessContent- Throws:
IOException
-