Package com.mckoi.store
Class StreamFile
- java.lang.Object
-
- com.mckoi.store.StreamFile
-
public class StreamFile extends java.lang.ObjectA RandomAccessFile that acts as an OutputStream, and can also be read as an InputStream.- Author:
- Tobias Downer
-
-
Constructor Summary
Constructors Constructor Description StreamFile(java.io.File file, java.lang.String mode)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the file.voiddelete()Deletes the file.java.io.InputStreamgetInputStream()Returns an InputStream to the file that allows us to read from the start to the end of the file.java.io.OutputStreamgetOutputStream()Opens an OutputStream to the file.longlength()Returns the current length of the data.voidreadFully(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.voidsynch()Synchs the file.
-
-
-
Method Detail
-
close
public void close() throws java.io.IOExceptionCloses the file.- Throws:
java.io.IOException
-
synch
public void synch() throws java.io.IOExceptionSynchs the file.- Throws:
java.io.IOException
-
delete
public void delete() throws java.io.IOExceptionDeletes the file.- Throws:
java.io.IOException
-
readFully
public void readFully(long position, byte[] buf, int off, int len) throws java.io.IOExceptionFully reads a block from a section of the file into the given byte[] array at the given position.- Throws:
java.io.IOException
-
length
public long length()
Returns the current length of the data.
-
getOutputStream
public java.io.OutputStream getOutputStream() throws java.io.IOExceptionOpens an OutputStream to the file. Only one output stream may be open on the file at once.- Throws:
java.io.IOException
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOExceptionReturns an InputStream to the file that allows us to read from the start to the end of the file.- Throws:
java.io.IOException
-
-