Package io.milton.common
Class RandomFileOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- io.milton.common.RandomFileOutputStream
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
public class RandomFileOutputStream extends OutputStream
A positionable file output stream.Threading Design : [x] Single Threaded [ ] Threadsafe [ ] Immutable [ ] Isolated From http://stackoverflow.com/questions/825732/how-can-i-implement-an-outputstream-that-i-can-rewind
-
-
Field Summary
Fields Modifier and Type Field Description protected RandomAccessFilerandomFileprotected booleansync
-
Constructor Summary
Constructors Constructor Description RandomFileOutputStream(File fil)RandomFileOutputStream(File fil, boolean syn)RandomFileOutputStream(String fnm)RandomFileOutputStream(String fnm, boolean syn)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidflush()FileDescriptorgetFD()longgetFilePointer()longgetFileSize()voidsetFilePointer(long pos)voidsetFileSize(long len)voidwrite(byte[] val)voidwrite(byte[] val, int off, int len)voidwrite(int val)-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Field Detail
-
randomFile
protected RandomAccessFile randomFile
-
sync
protected boolean sync
-
-
Constructor Detail
-
RandomFileOutputStream
public RandomFileOutputStream(String fnm) throws IOException
- Throws:
IOException
-
RandomFileOutputStream
public RandomFileOutputStream(String fnm, boolean syn) throws IOException
- Throws:
IOException
-
RandomFileOutputStream
public RandomFileOutputStream(File fil) throws IOException
- Throws:
IOException
-
RandomFileOutputStream
public RandomFileOutputStream(File fil, boolean syn) throws IOException
- Throws:
IOException
-
-
Method Detail
-
write
public void write(int val) throws IOException- Specified by:
writein classOutputStream- Throws:
IOException
-
write
public void write(byte[] val) throws IOException- Overrides:
writein classOutputStream- Throws:
IOException
-
write
public void write(byte[] val, int off, int len) throws IOException- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
public void flush() throws IOException- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
getFilePointer
public long getFilePointer() throws IOException- Throws:
IOException
-
setFilePointer
public void setFilePointer(long pos) throws IOException- Throws:
IOException
-
getFileSize
public long getFileSize() throws IOException- Throws:
IOException
-
setFileSize
public void setFileSize(long len) throws IOException- Throws:
IOException
-
getFD
public FileDescriptor getFD() throws IOException
- Throws:
IOException
-
-