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 protected
RandomAccessOutputStream(java.io.OutputStream dist)
-
Method Summary
Modifier and Type Method Description void
close()
abstract void
disposeBefore(long pos)
protected void
ensureOpen()
Check to make sure that this stream has not been closedprotected void
finalize()
short
getEndian()
abstract long
getFlushPos()
abstract long
getLength()
Returns the total length of data that has been cached, regardless of whether any early blocks have been disposed.abstract long
getStreamPointer()
abstract void
reset()
Reset this stream to be used againabstract void
seek(long pos)
void
setWriteStrategy(WriteStrategy strategy)
abstract void
shallowClose()
Closes the RandomAccessInputStream and it's underlying streamabstract void
write(byte[] b, int off, int len)
abstract void
write(int value)
void
writeBoolean(boolean value)
void
writeByte(int value)
void
writeBytes(java.lang.String value)
void
writeChar(int value)
void
writeChars(java.lang.String value)
void
writeDouble(double value)
void
writeFloat(float value)
void
writeInt(int value)
void
writeLong(long value)
void
writeS15Fixed16Number(float value)
void
writeShort(int value)
abstract void
writeToStream(long len)
void
writeU16Fixed16Number(float value)
void
writeU8Fixed8Number(float value)
void
writeUTF(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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in 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:
finalize
in 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:
write
in interfacejava.io.DataOutput
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public abstract void write(int value) throws java.io.IOException- Specified by:
write
in interfacejava.io.DataOutput
- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
writeBoolean
public final void writeBoolean(boolean value) throws java.io.IOException- Specified by:
writeBoolean
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeByte
public final void writeByte(int value) throws java.io.IOException- Specified by:
writeByte
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeBytes
public final void writeBytes(java.lang.String value) throws java.io.IOException- Specified by:
writeBytes
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeChar
public final void writeChar(int value) throws java.io.IOException- Specified by:
writeChar
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeChars
public final void writeChars(java.lang.String value) throws java.io.IOException- Specified by:
writeChars
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeDouble
public final void writeDouble(double value) throws java.io.IOException- Specified by:
writeDouble
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeFloat
public final void writeFloat(float value) throws java.io.IOException- Specified by:
writeFloat
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeInt
public final void writeInt(int value) throws java.io.IOException- Specified by:
writeInt
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeLong
public final void writeLong(long value) throws java.io.IOException- Specified by:
writeLong
in 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:
writeShort
in 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:
writeUTF
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-