public class MemoryCacheImageOutputStream extends ImageOutputStreamImpl
ImageOutputStream ,将其输出写入常规的OutputStream 。
存储器缓冲器用于至少缓存丢弃位置和当前写入位置之间的数据。
唯一的构造函数需要一个OutputStream ,所以这个类可能不用于读/修改/写操作。
读取只能发生在已经写入高速缓存并且尚未刷新的流的部分上。
bitOffset, byteOrder, flushedPos, streamPos| Constructor and Description |
|---|
MemoryCacheImageOutputStream(OutputStream stream)
构造一个
MemoryCacheImageOutputStream ,它将写入给定的
OutputStream 。
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
关闭此
MemoryCacheImageOutputStream 。
|
void |
flushBefore(long pos)
在指示的位置之前丢弃流的初始部分。
|
boolean |
isCached()
返回
true因为这
ImageOutputStream缓存数据,以便向后追溯。
|
boolean |
isCachedFile()
返回
false因为这个
ImageOutputStream没有维护一个文件缓存。
|
boolean |
isCachedMemory()
返回
true因为这
ImageOutputStream维护一个主内存缓存。
|
long |
length()
返回
-1L以表示该流具有未知长度。
|
int |
read()
从流中读取一个字节,并将其作为0和255之间的
int返回。
|
int |
read(byte[] b, int off, int len)
读取到
len从流字节,并将其存储到
b开始于索引
off 。
|
void |
write(byte[] b, int off, int len)
在当前位置写入一串字节。
|
void |
write(int b)
将当前位置的单个字节写入流。
|
flushBits, write, writeBit, writeBits, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeChars, writeDouble, writeDoubles, writeFloat, writeFloats, writeInt, writeInts, writeLong, writeLongs, writeShort, writeShorts, writeUTFcheckClosed, finalize, flush, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, mark, read, readBit, readBits, readBoolean, readByte, readBytes, readChar, readDouble, readFloat, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUTF, reset, seek, setBitOffset, setByteOrder, skipBytes, skipBytesclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitflush, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, mark, read, readBit, readBits, readBoolean, readByte, readBytes, readChar, readDouble, readFloat, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUTF, reset, seek, setBitOffset, setByteOrder, skipBytes, skipBytespublic MemoryCacheImageOutputStream(OutputStream stream)
MemoryCacheImageOutputStream ,它将写入给定的
OutputStream 。
stream -
OutputStream 。
IllegalArgumentException - 如果
stream是
null 。
public int read()
throws IOException
ImageInputStreamImpl复制
int 255之间0和如果达到EOF, -1被返回。
子类必须为此方法提供一个实现。 子类实现应该在退出之前更新流位置。
在发生读取之前,流内的位偏移必须重置为零。
read在接口
ImageInputStream
read在
ImageInputStreamImpl
-1 。
IOException - 如果流已关闭。
public int read(byte[] b,
int off,
int len)
throws IOException
ImageInputStreamImpl
len从流字节,并将其存储到b开始于索引off 。
如果没有字节可以读取,因为已经到达流的末尾,则返回-1 。
在发生读取之前,流内的位偏移必须重置为零。
子类必须为此方法提供一个实现。 子类实现应该在退出之前更新流位置。
read在接口
ImageInputStream
read在
ImageInputStreamImpl
b - 要写入的字节数组。
off - 起始位置内写入
b 。
len - 要读取的最大字节数。
-1表示EOF。
IOException - 如果发生I / O错误。
public void write(int b)
throws IOException
ImageOutputStream
b的24个高位被忽略。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。 实施者可以使用flushBits的方法ImageOutputStreamImpl保证这一点。
write在接口
DataOutput
write在接口
ImageOutputStream
write在
ImageOutputStreamImpl
b - 要写入低8位的
int 。
IOException - 如果发生I / O错误。
public void write(byte[] b,
int off,
int len)
throws IOException
ImageOutputStream复制
len为0,则不写任何内容。
字节b[off]先写,然后字节b[off + 1]等等。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。 实施者可以使用flushBits的方法ImageOutputStreamImpl保证这一点。
write中的
DataOutput
write在接口
ImageOutputStream
write在
ImageOutputStreamImpl
b - 要写入的数组
byte 。
off - 数据中的起始偏移量。
len -数量
byte s到写。
IOException - 如果发生I / O错误。
public long length()
ImageInputStreamImpl
-1L以表示该流具有未知长度。
子类必须覆盖此方法以提供实际的长度信息。
length在接口
ImageInputStream
length在
ImageInputStreamImpl
public boolean isCached()
true因为这
ImageOutputStream缓存数据,以便向后追溯。
isCached中的
ImageInputStream
isCached在
ImageInputStreamImpl
true 。
isCachedMemory() ,
isCachedFile()
public boolean isCachedFile()
false因为这个
ImageOutputStream没有维护一个文件缓存。
isCachedFile在接口
ImageInputStream
isCachedFile在
ImageInputStreamImpl
false 。
isCached() ,
isCachedMemory()
public boolean isCachedMemory()
true因为这
ImageOutputStream维护一个主内存缓存。
isCachedMemory在接口
ImageInputStream
isCachedMemory在
ImageInputStreamImpl
true 。
isCached() ,
isCachedFile()
public void close()
throws IOException
MemoryCacheImageOutputStream 。
所有挂起的数据都被刷新到输出,缓存被释放。
目的地OutputStream未关闭。
close在接口
Closeable
close在接口
AutoCloseable
close在接口
ImageInputStream
close在
ImageInputStreamImpl
IOException - 如果发生I / O错误。
public void flushBefore(long pos)
throws IOException
ImageInputStream复制
IndexOutOfBoundsException 。
调用flushBefore可能允许实现此接口的类释放用于从流中存储数据的资源(如内存或磁盘空间)。
flushBefore在接口
ImageInputStream
flushBefore在接口
ImageOutputStream
flushBefore在
ImageInputStreamImpl
pos - 一个
long可能被刷新的流前缀的长度的long。
IOException - 如果发生I / O错误。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.