public class FileCacheImageInputStream extends ImageInputStreamImpl
ImageInputStream从正规获取输入InputStream 。
一个文件用于缓存先前读取的数据。
bitOffset, byteOrder, flushedPos, streamPos| Constructor and Description |
|---|
FileCacheImageInputStream(InputStream stream, File cacheDir)
构造一个
FileCacheImageInputStream ,它将从给定的
InputStream读取。
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
关闭此
FileCacheImageInputStream ,关闭并删除缓存文件。
|
protected void |
finalize()
在垃圾收集之前完成此对象。
|
boolean |
isCached()
返回
true因为
ImageInputStream缓存数据以允许向后搜索。
|
boolean |
isCachedFile()
返回
true因为这个
ImageInputStream维护一个文件缓存。
|
boolean |
isCachedMemory()
返回
false因为这个
ImageInputStream没有维护主内存缓存。
|
int |
read()
从流中读取一个字节,并将其作为从0到255之间的
int返回。
|
int |
read(byte[] b, int off, int len)
读取到
len从流字节,并将其存储到
b开始于索引
off 。
|
checkClosed, flush, flushBefore, 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 FileCacheImageInputStream(InputStream stream, File cacheDir) throws IOException
FileCacheImageInputStream ,它将从给定的InputStream读取。
临时文件用作缓存。 如果cacheDir是非null并且是一个目录,该文件将在那里创建。 如果是null ,将使用系统相关的默认临时文件目录(有关详细信息,请参阅File.createTempFile的File.createTempFile )。
stream - 要阅读的
InputStream 。
cacheDir - 一个
File指示应该创建高速缓存文件的位置,或
null使用系统目录。
IllegalArgumentException - 如果
stream是
null 。
IllegalArgumentException - 如果
cacheDir是非
null但不是一个目录。
IOException - 如果无法创建缓存文件。
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 boolean isCached()
true因为
ImageInputStream缓存数据以允许向后搜索。
isCached在界面
ImageInputStream
isCached在类别
ImageInputStreamImpl
true 。
isCachedMemory() ,
isCachedFile()
public boolean isCachedFile()
true因为
ImageInputStream维护文件缓存。
isCachedFile在界面
ImageInputStream
isCachedFile在类别
ImageInputStreamImpl
true 。
isCached() ,
isCachedMemory()
public boolean isCachedMemory()
false因为
ImageInputStream不维护主内存缓存。
isCachedMemory在接口
ImageInputStream
isCachedMemory在类别
ImageInputStreamImpl
false 。
isCached() ,
isCachedFile()
public void close()
throws IOException
FileCacheImageInputStream ,关闭并删除缓存文件。
源InputStream未关闭。
close在界面
Closeable
close接口
AutoCloseable
close在界面
ImageInputStream
close在类别
ImageInputStreamImpl
IOException - 如果发生错误。
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.