public interface RandomAccessContent
extends java.io.DataOutput, java.io.DataInput, java.io.Closeable
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.
|
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.
|
void close() throws java.io.IOException
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.
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
java.io.IOException
- if an I/O error occurs.long getFilePointer() throws java.io.IOException
java.io.IOException
- if an I/O error occurs.java.io.InputStream getInputStream() throws java.io.IOException
Notice: If you use seek(long)
you have to re-get the InputStream
java.io.IOException
- if an I/O error occurs.long length() throws java.io.IOException
java.io.IOException
- if an I/O error occurs.void seek(long pos) throws java.io.IOException
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 getInputStream()
you have to re-get the InputStream after calling
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.void setLength(long newLength) throws java.io.IOException
If the the newLength
argument is smaller than length()
, the content is truncated.
If the the newLength
argument is greater than length()
, the content grows with undefined data.
newLength
- The desired content lengthjava.io.IOException
- If an I/O error occurs