Package pixy.io
Class RandomAccessOutputStream
java.lang.Object
java.io.OutputStream
pixy.io.RandomAccessOutputStream
- All Implemented Interfaces:
java.io.Closeable,java.io.DataOutput,java.io.Flushable,java.lang.AutoCloseable
- Direct Known Subclasses:
FileCacheRandomAccessOutputStream,MemoryCacheRandomAccessOutputStream
public abstract class RandomAccessOutputStream
extends java.io.OutputStream
implements java.io.DataOutput
Based on javax.imageio.stream.MemoryCache.java.
*
To make it flexible, this class and any of its sub-class doesn't close the underlying stream. It's up to the underlying stream creator to close them. This ensures the actual stream out-lives the random stream itself in case we need to write more content to the underlying stream.
- Version:
- 1.0 01/29/2013
- Author:
- Wen Yu, yuwen_66@yahoo.com
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protectedRandomAccessOutputStream(java.io.OutputStream dist) -
Method Summary
Modifier and Type Method Description voidclose()abstract voiddisposeBefore(long pos)protected voidensureOpen()Check to make sure that this stream has not been closedprotected voidfinalize()shortgetEndian()abstract longgetFlushPos()abstract longgetLength()Returns the total length of data that has been cached, regardless of whether any early blocks have been disposed.abstract longgetStreamPointer()abstract voidreset()Reset this stream to be used againabstract voidseek(long pos)voidsetWriteStrategy(WriteStrategy strategy)abstract voidshallowClose()Closes the RandomAccessInputStream and it's underlying streamabstract voidwrite(byte[] b, int off, int len)abstract voidwrite(int value)voidwriteBoolean(boolean value)voidwriteByte(int value)voidwriteBytes(java.lang.String value)voidwriteChar(int value)voidwriteChars(java.lang.String value)voidwriteDouble(double value)voidwriteFloat(float value)voidwriteInt(int value)voidwriteLong(long value)voidwriteS15Fixed16Number(float value)voidwriteShort(int value)abstract voidwriteToStream(long len)voidwriteU16Fixed16Number(float value)voidwriteU8Fixed8Number(float value)voidwriteUTF(java.lang.String value)
-
Field Details
-
Constructor Details
-
RandomAccessOutputStream
protected RandomAccessOutputStream(java.io.OutputStream dist)
-
-
Method Details
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
shallowClose
public abstract void shallowClose() throws java.io.IOExceptionCloses the RandomAccessInputStream and it's underlying stream- Throws:
java.io.IOException
-
ensureOpen
protected void ensureOpen() throws java.io.IOExceptionCheck to make sure that this stream has not been closed- Throws:
java.io.IOException
-
disposeBefore
public abstract void disposeBefore(long pos) throws java.io.IOException- Throws:
java.io.IOException
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
getEndian
public short getEndian() -
getFlushPos
public abstract long getFlushPos() -
getLength
public abstract long getLength()Returns the total length of data that has been cached, regardless of whether any early blocks have been disposed. This value will only ever increase.- Throws:
java.io.IOException
-
getStreamPointer
public abstract long getStreamPointer()- Returns:
- the current stream position
- Throws:
java.io.IOException
-
reset
public abstract void reset()Reset this stream to be used again -
seek
public abstract void seek(long pos) throws java.io.IOException- Throws:
java.io.IOException
-
setWriteStrategy
-
write
public abstract void write(byte[] b, int off, int len) throws java.io.IOException- Specified by:
writein interfacejava.io.DataOutput- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public abstract void write(int value) throws java.io.IOException- Specified by:
writein interfacejava.io.DataOutput- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
writeBoolean
public final void writeBoolean(boolean value) throws java.io.IOException- Specified by:
writeBooleanin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeByte
public final void writeByte(int value) throws java.io.IOException- Specified by:
writeBytein interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeBytes
public final void writeBytes(java.lang.String value) throws java.io.IOException- Specified by:
writeBytesin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeChar
public final void writeChar(int value) throws java.io.IOException- Specified by:
writeCharin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeChars
public final void writeChars(java.lang.String value) throws java.io.IOException- Specified by:
writeCharsin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeDouble
public final void writeDouble(double value) throws java.io.IOException- Specified by:
writeDoublein interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeFloat
public final void writeFloat(float value) throws java.io.IOException- Specified by:
writeFloatin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeInt
public final void writeInt(int value) throws java.io.IOException- Specified by:
writeIntin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeLong
public final void writeLong(long value) throws java.io.IOException- Specified by:
writeLongin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeS15Fixed16Number
public final void writeS15Fixed16Number(float value) throws java.io.IOException- Throws:
java.io.IOException
-
writeShort
public final void writeShort(int value) throws java.io.IOException- Specified by:
writeShortin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeToStream
public abstract void writeToStream(long len) throws java.io.IOException- Throws:
java.io.IOException
-
writeU16Fixed16Number
public final void writeU16Fixed16Number(float value) throws java.io.IOException- Throws:
java.io.IOException
-
writeU8Fixed8Number
public final void writeU8Fixed8Number(float value) throws java.io.IOException- Throws:
java.io.IOException
-
writeUTF
public final void writeUTF(java.lang.String value) throws java.io.IOException- Specified by:
writeUTFin interfacejava.io.DataOutput- Throws:
java.io.IOException
-