java.lang.Object
javax.imageio.stream.ImageInputStreamImpl
javax.imageio.stream.ImageOutputStreamImpl
javax.imageio.stream.FileImageOutputStream
- 所有已实现的接口:
Closeable
,DataInput
,DataOutput
,AutoCloseable
,ImageInputStream
,ImageOutputStream
ImageOutputStream
的实现,将其输出直接写入 File
或 RandomAccessFile
。
-
字段摘要
在类 javax.imageio.stream.ImageInputStreamImpl 中声明的字段
bitOffset, byteOrder, flushedPos, streamPos
-
构造方法总结
构造方法构造方法描述构造一个将写入给定File
的FileImageOutputStream
。构造一个将写入给定RandomAccessFile
的FileImageOutputStream
。 -
方法总结
修饰符和类型方法描述void
close()
关闭流。protected void
finalize()
已弃用,将被删除:此 API 元素可能会在未来版本中删除。Finalization 已被弃用以移除。long
length()
返回-1L
以指示流的长度未知。int
read()
从流中读取单个字节并将其作为 0 到 255 之间的int
返回。int
read
(byte[] b, int off, int len) 从流中读取最多len
个字节,并将它们存储到从索引off
开始的b
中。void
seek
(long pos) 设置当前流位置并将位偏移重置为 0。void
write
(byte[] b, int off, int len) 在当前位置将字节序列写入流。void
write
(int b) 在当前位置将单个字节写入流。在类 javax.imageio.stream.ImageOutputStreamImpl 中声明的方法
flushBits, write, writeBit, writeBits, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeChars, writeDouble, writeDoubles, writeFloat, writeFloats, writeInt, writeInts, writeLong, writeLongs, writeShort, writeShorts, writeUTF
在类 javax.imageio.stream.ImageInputStreamImpl 中声明的方法
checkClosed, close, flush, flushBefore, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, isCached, isCachedFile, isCachedMemory, 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, setBitOffset, setByteOrder, skipBytes, skipBytes
在类 java.lang.Object 中声明的方法
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
在接口 javax.imageio.stream.ImageInputStream 中声明的方法
flush, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, isCached, isCachedFile, isCachedMemory, 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, setBitOffset, setByteOrder, skipBytes, skipBytes
在接口 javax.imageio.stream.ImageOutputStream 中声明的方法
flushBefore
-
构造方法详细信息
-
FileImageOutputStream
构造一个将写入给定File
的FileImageOutputStream
。- 参数:
f
- 要写入的File
。- 抛出:
IllegalArgumentException
- 如果f
是null
。SecurityException
- 如果安全管理器存在并且不允许对该文件进行写访问。FileNotFoundException
- 如果f
不表示常规文件或由于任何其他原因无法打开以进行读写。IOException
- 如果发生 I/O 错误。
-
FileImageOutputStream
构造一个将写入给定RandomAccessFile
的FileImageOutputStream
。- 参数:
raf
- 要写入的RandomAccessFile
。- 抛出:
IllegalArgumentException
- 如果raf
是null
。
-
-
方法详情
-
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
- 一个int
,其低 8 位将被写入。- 抛出:
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 表示未知长度。
-
seek
设置当前流位置并将位偏移重置为 0。查找文件末尾是合法的;仅当执行读取时才会抛出EOFException
。在执行写入之前,文件长度不会增加。- 参数:
pos
- 包含所需文件指针位置的long
。- 抛出:
IndexOutOfBoundsException
- 如果pos
小于冲洗位置。IOException
- 如果发生任何其他 I/O 错误。
-
close
从接口ImageInputStream
复制的描述关闭流。尝试访问已关闭的流可能会导致IOException
或不正确的行为。调用此方法可能允许实现此接口的类释放与流关联的资源,例如内存、磁盘空间或文件描述符。- 抛出:
IOException
- 如果发生 I/O 错误。
-
finalize
已弃用,将被删除:此 API 元素可能会在未来版本中删除。Finalization 已被弃用以移除。有关迁移选项的背景信息和详细信息,请参阅Object.finalize()
。在垃圾收集之前完成此对象。close
方法被调用以关闭任何打开的输入源。不应从应用程序代码中调用此方法。- 重写:
finalize
在类ImageInputStreamImpl
中- 抛出:
Throwable
- 如果在超类完成期间发生错误。- 参见:
-