public class MemoryCacheImageInputStream extends ImageInputStreamImpl
ImageInputStream从正规获取输入InputStream 。
存储器缓冲器用于至少缓存丢弃位置和当前读取位置之间的数据。
一般地,它是优选使用FileCacheImageInputStream从常规读出时InputStream 。 在不可能创建可写入临时文件的情况下提供此类。
bitOffset, byteOrder, flushedPos, streamPos| Constructor and Description |
|---|
MemoryCacheImageInputStream(InputStream stream)
构造一个
MemoryCacheImageInputStream ,它将从给定的
InputStream读取。
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
关闭此
MemoryCacheImageInputStream ,释放缓存。
|
protected void |
finalize()
在垃圾收集之前完成此对象。
|
void |
flushBefore(long pos)
在指示的位置之前丢弃流的初始部分。
|
boolean |
isCached()
返回
true因为
ImageInputStream缓存数据以允许向后搜索。
|
boolean |
isCachedFile()
返回
false因为这个
ImageInputStream没有维护文件缓存。
|
boolean |
isCachedMemory()
返回
true因为这个
ImageInputStream维护一个主内存缓存。
|
int |
read()
从流中读取一个字节,并将其作为从0到255之间的
int返回。
|
int |
read(byte[] b, int off, int len)
读取到
len从流字节,并将其存储到
b开始于索引
off 。
|
checkClosed, flush, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, length, 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 MemoryCacheImageInputStream(InputStream stream)
MemoryCacheImageInputStream ,将从给定的
InputStream读取。
stream - 要阅读的
InputStream 。
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 flushBefore(long pos)
throws IOException
ImageInputStream复制
IndexOutOfBoundsException 。
调用flushBefore可能允许实现此接口的类释放用于存储流中的数据的资源(如内存或磁盘空间)。
flushBefore在界面
ImageInputStream
flushBefore在
ImageInputStreamImpl
pos - 一个
long其中包含可能被刷新的流前缀的长度。
IOException - 如果发生I / O错误。
public boolean isCached()
true因为这
ImageInputStream缓存数据,以便向后追溯。
isCached在界面
ImageInputStream
isCached在
ImageInputStreamImpl
true 。
isCachedMemory() ,
isCachedFile()
public boolean isCachedFile()
false因为这个
ImageInputStream没有维护一个文件缓存。
isCachedFile在接口
ImageInputStream
isCachedFile在
ImageInputStreamImpl
false 。
isCached() ,
isCachedMemory()
public boolean isCachedMemory()
true因为这
ImageInputStream维护一个主内存缓存。
isCachedMemory在接口
ImageInputStream
isCachedMemory在
ImageInputStreamImpl
true 。
isCached() ,
isCachedFile()
public void close()
throws IOException
MemoryCacheImageInputStream ,释放缓存。
来源InputStream未关闭。
close中的
Closeable
close在界面
AutoCloseable
close在界面
ImageInputStream
close在类
ImageInputStreamImpl
IOException - 如果发生I / O错误。
protected void finalize()
throws Throwable
close方法来关闭任何打开的输入源。
不应该从应用程序代码调用此方法。
finalize在
ImageInputStreamImpl
Throwable - 如果在超类最终化期间发生错误。
WeakReference , PhantomReference
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.