java.lang.Object
javax.imageio.stream.ImageInputStreamImpl
javax.imageio.stream.FileCacheImageInputStream
- 所有已实现的接口:
-
Closeable,DataInput,AutoCloseable,ImageInputStream
一个实现了
ImageInputStream接口的类,从常规InputStream获取输入。使用文件来缓存先前读取的数据。
-
Field Summary
Fields declared in class javax.imageio.stream.ImageInputStreamImpl
bitOffset, byteOrder, flushedPos, streamPos -
Constructor Summary
ConstructorsConstructorDescriptionFileCacheImageInputStream(InputStream stream, File cacheDir) 构造一个FileCacheImageInputStream,将从给定的InputStream读取。 -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()关闭这个FileCacheImageInputStream,关闭并移除缓存文件。protected voidfinalize()已弃用,将被移除: 该API元素可能在将来的版本中被移除。终结已被标记为将来移除。booleanisCached()返回true,因为这个ImageInputStream缓存数据以允许向后查找。boolean返回true,因为这个ImageInputStream维护一个文件缓存。boolean返回false,因为这个ImageInputStream不维护主内存缓存。intread()从流中读取一个字节并将其作为介于0和255之间的int返回。intread(byte[] b, int off, int len) 从流中读取最多len个字节,并将它们存储到从索引off开始的b中。Methods declared in class javax.imageio.stream.ImageInputStreamImpl
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, skipBytes
-
Constructor Details
-
FileCacheImageInputStream
构造一个FileCacheImageInputStream,将从给定的InputStream读取。一个临时文件被用作缓存。如果
cacheDir非null且是一个目录,则文件将在那里创建。如果它是null,则将使用系统相关的默认临时文件目录(有关详细信息,请参阅File.createTempFile的文档)。- 参数:
-
stream- 用于读取的InputStream。 -
cacheDir- 指示缓存文件应该创建在哪里的File,或者为了使用系统目录而是null。 - 抛出:
-
IllegalArgumentException- 如果stream为null。 -
IllegalArgumentException- 如果cacheDir非null但不是目录。 -
IOException- 如果无法创建缓存文件。
-
-
Method Details
-
read
从类中复制的描述:ImageInputStreamImpl从流中读取一个字节并将其作为介于0和255之间的int返回。如果达到EOF,则返回-1。子类必须为此方法提供实现。子类的实现应在退出之前更新流位置。
在读取发生之前,流中的位偏移必须重置为零。
- 指定由:
-
read在接口ImageInputStream - 指定由:
-
read在类ImageInputStreamImpl - 返回:
-
流中下一个字节的值,如果达到EOF则返回
-1。 - 抛出:
-
IOException- 如果流已关闭。
-
read
从类中复制的描述:ImageInputStreamImpl从流中读取最多len个字节,并将它们存储到从索引off开始的b中。如果无法读取任何字节,因为已到达流的末尾,则返回-1。在读取发生之前,流中的位偏移必须重置为零。
子类必须为此方法提供实现。子类的实现应在退出之前更新流位置。
- 指定由:
-
read在接口ImageInputStream - 指定由:
-
read在类ImageInputStreamImpl - 参数:
-
b- 要写入的字节数组。 -
off- 要写入的b中的起始位置。 -
len- 要读取的最大字节数。 - 返回:
-
实际读取的字节数,或
-1表示EOF。 - 抛出:
-
IOException- 如果发生I/O错误。
-
isCached
public boolean isCached()返回true,因为这个ImageInputStream缓存数据以允许向后查找。- 指定由:
-
isCached在接口ImageInputStream - 覆盖:
-
isCached在类ImageInputStreamImpl - 返回:
-
true。 - 参见:
-
isCachedFile
public boolean isCachedFile()返回true,因为这个ImageInputStream维护一个文件缓存。- 指定由:
-
isCachedFile在接口ImageInputStream - 覆盖:
-
isCachedFile在类ImageInputStreamImpl - 返回:
-
true。 - 参见:
-
isCachedMemory
public boolean isCachedMemory()返回false,因为这个ImageInputStream不维护主内存缓存。- 指定由:
-
isCachedMemory在接口ImageInputStream - 覆盖:
-
isCachedMemory在类ImageInputStreamImpl - 返回:
-
false。 - 参见:
-
close
关闭这个FileCacheImageInputStream,关闭并移除缓存文件。源InputStream不会被关闭。- 抛出:
-
IOException- 如果发生错误。
-
finalize
Deprecated, for removal: This API element is subject to removal in a future version.Finalization has been deprecated for removal. SeeObject.finalize()for background information and details about migration options.在垃圾回收之前完成此对象的终结。将调用close方法来关闭任何打开的输入源。此方法不应该从应用程序代码中调用。- 覆盖:
-
finalize在类ImageInputStreamImpl - 抛出:
-
Throwable- 如果在超类终结期间发生错误。 - 参见:
-