java.lang.Object
javax.imageio.stream.ImageInputStreamImpl
javax.imageio.stream.ImageOutputStreamImpl
javax.imageio.stream.MemoryCacheImageOutputStream
- 所有已实现的接口:
-
Closeable,DataInput,DataOutput,AutoCloseable,ImageInputStream,ImageOutputStream
实现了
ImageOutputStream,将其输出写入常规OutputStream的类。使用内存缓冲区来缓存至少处于丢弃位置和当前写入位置之间的数据。唯一的构造函数接受一个OutputStream,因此此类不能用于读取/修改/写入操作。只能在已写入缓存但尚未刷新的流的部分上进行读取。
-
Field Summary
Fields declared in class javax.imageio.stream.ImageInputStreamImpl
bitOffset, byteOrder, flushedPos, streamPos -
Constructor Summary
ConstructorsConstructorDescription构造一个将写入给定OutputStream的MemoryCacheImageOutputStream。 -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()关闭此MemoryCacheImageOutputStream。voidflushBefore(long pos) 刷新到给定位置之前的所有数据到底层目标,如OutputStream或File。booleanisCached()返回true,因为此ImageOutputStream缓存数据以允许向后查找。boolean返回false,因为此ImageOutputStream不维护文件缓存。boolean返回true,因为此ImageOutputStream维护主内存缓存。longlength()返回-1L,表示流的长度未知。intread()从流中读取一个字节并将其作为介于0和255之间的int返回。intread(byte[] b, int off, int len) 从流中读取最多len字节,并将它们存储到从索引off开始的b中。voidwrite(byte[] b, int off, int len) 将一系列字节写入当前位置的流。voidwrite(int b) 将一个字节写入当前位置的流。Methods declared in class javax.imageio.stream.ImageOutputStreamImpl
flushBits, write, writeBit, writeBits, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeChars, writeDouble, writeDoubles, writeFloat, writeFloats, writeInt, writeInts, writeLong, writeLongs, writeShort, writeShorts, writeUTFMethods declared in class javax.imageio.stream.ImageInputStreamImpl
checkClosed, finalize, 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, skipBytesMethods declared in class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods declared in interface javax.imageio.stream.ImageInputStream
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, skipBytes
-
Constructor Details
-
MemoryCacheImageOutputStream
构造一个将写入给定OutputStream的MemoryCacheImageOutputStream。- 参数:
-
stream- 要写入的OutputStream。 - 抛出:
-
IllegalArgumentException- 如果stream为null。
-
-
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错误。
-
write
从接口中复制的描述:ImageOutputStream将一个字节写入当前位置的流。忽略b的高24位。如果流中的位偏移不为零,则当前字节的其余部分将填充为0并首先写出。写入后,位偏移将为0。实现者可以使用
ImageOutputStreamImpl的flushBits方法来保证这一点。- 参数:
-
b- 要写入其低8位的int。 - 抛出:
-
IOException- 如果发生I/O错误。
-
write
从接口中复制的描述:ImageOutputStream将一系列字节写入当前位置的流。如果len为0,则不写入任何内容。首先写入字节b[off],然后是字节b[off + 1],依此类推。如果流中的位偏移不为零,则当前字节的其余部分将填充为0并首先写出。写入后,位偏移将为0。实现者可以使用
ImageOutputStreamImpl的flushBits方法来保证这一点。- 参数:
-
b- 要写入的byte数组。 -
off- 数据中的起始偏移量。 -
len- 要写入的byte数。 - 抛出:
-
IOException- 如果发生I/O错误。
-
length
public long length()从类中复制的描述:ImageInputStreamImpl返回-1L,表示流的长度未知。子类必须重写此方法以提供实际长度信息。- 指定者:
-
length在接口ImageInputStream中 - 覆盖:
-
length在类ImageInputStreamImpl中 - 返回:
- -1L表示长度未知。
-
isCached
public boolean isCached()返回true,因为此ImageOutputStream缓存数据以允许向后查找。- 指定者:
-
isCached在接口ImageInputStream中 - 覆盖:
-
isCached在类ImageInputStreamImpl中 - 返回:
-
true。 - 参见:
-
isCachedFile
public boolean isCachedFile()返回false,因为此ImageOutputStream不维护文件缓存。- 指定者:
-
isCachedFile在接口ImageInputStream中 - 覆盖:
-
isCachedFile在类ImageInputStreamImpl中 - 返回:
-
false。 - 参见:
-
isCachedMemory
public boolean isCachedMemory()返回true,因为此ImageOutputStream维护主内存缓存。- 指定由:
-
isCachedMemory在接口ImageInputStream - 覆盖:
-
isCachedMemory在类ImageInputStreamImpl - 返回:
-
true. - 参见:
-
close
关闭这个MemoryCacheImageOutputStream。所有待处理数据都会刷新到输出,缓存将被释放。目标OutputStream不会被关闭。- 抛出:
-
IOException- 如果发生I/O错误。
-
flushBefore
从接口复制的描述:ImageOutputStream刷新给定位置之前的所有数据到底层目标,比如一个OutputStream或File。尝试定位到流的刷新部分将导致IndexOutOfBoundsException。- 参数:
-
pos- 包含可能刷新到目标的流前缀的长度的long。 - 抛出:
-
IOException- 如果发生I/O错误。
-