Package com.mckoi.store
Class StreamFile
java.lang.Object
com.mckoi.store.StreamFile
A RandomAccessFile that acts as an OutputStream, and can also be read as an
InputStream.
- Author:
- Tobias Downer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the file.void
delete()
Deletes the file.Returns an InputStream to the file that allows us to read from the start to the end of the file.Opens an OutputStream to the file.long
length()
Returns the current length of the data.void
readFully
(long position, byte[] buf, int off, int len) Fully reads a block from a section of the file into the given byte[] array at the given position.void
synch()
Synchs the file.
-
Constructor Details
-
StreamFile
Constructor.- Throws:
IOException
-
-
Method Details
-
close
Closes the file.- Throws:
IOException
-
synch
Synchs the file.- Throws:
IOException
-
delete
Deletes the file.- Throws:
IOException
-
readFully
Fully reads a block from a section of the file into the given byte[] array at the given position.- Throws:
IOException
-
length
public long length()Returns the current length of the data. -
getOutputStream
Opens an OutputStream to the file. Only one output stream may be open on the file at once.- Throws:
IOException
-
getInputStream
Returns an InputStream to the file that allows us to read from the start to the end of the file.- Throws:
IOException
-