public class FileImageOutputStream extends ImageOutputStreamImpl
ImageOutputStream将其输出直接写入
File或
RandomAccessFile 。
bitOffset, byteOrder, flushedPos, streamPos| Constructor and Description |
|---|
FileImageOutputStream(File f)
构造一个
FileImageOutputStream ,它将写入给定的
File 。
|
FileImageOutputStream(RandomAccessFile raf)
构造一个
FileImageOutputStream ,它将写入给定的
RandomAccessFile 。
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
关闭流。
|
protected void |
finalize()
在垃圾收集之前完成此对象。
|
long |
length()
返回
-1L以表示该流具有未知长度。
|
int |
read()
从流中读取一个字节,并将其作为0和255之间的
int返回。
|
int |
read(byte[] b, int off, int len)
从流中读取最多
len个字节,并将其存储在
b从索引
off开始。
|
void |
seek(long pos)
设置当前流位置,并将位偏移重置为0。
|
void |
write(byte[] b, int off, int len)
在当前位置写入一串字节。
|
void |
write(int b)
将当前位置的单个字节写入流。
|
flushBits, write, writeBit, writeBits, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeChars, writeDouble, writeDoubles, writeFloat, writeFloats, writeInt, writeInts, writeLong, writeLongs, writeShort, writeShorts, writeUTFcheckClosed, flush, flushBefore, 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, skipBytesclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitflushBeforeflush, 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, skipBytespublic FileImageOutputStream(File f) throws FileNotFoundException, IOException
FileImageOutputStream ,写入给定的
File 。
f - a
File写信给。
IllegalArgumentException - 如果
f是
null 。
SecurityException - 如果安全管理器存在并且不允许对该文件的写入访问。
FileNotFoundException - 如果
f不表示常规文件,或者由于任何其他原因无法打开读取和写入。
IOException - 如果发生I / O错误。
public FileImageOutputStream(RandomAccessFile raf)
FileImageOutputStream ,它将写入给定的
RandomAccessFile 。
raf - a
RandomAccessFile要写信给。
IllegalArgumentException - 如果
raf是
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 write(int b)
throws IOException
ImageOutputStream复制
b的24个高位被忽略。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。 实施者可以使用flushBits的方法ImageOutputStreamImpl保证这一点。
write在接口
DataOutput
write在接口
ImageOutputStream
write在
ImageOutputStreamImpl
b - 要写入低8位的
int 。
IOException - 如果发生I / O错误。
public void write(byte[] b,
int off,
int len)
throws IOException
ImageOutputStream复制
len为0,则不写任何内容。
字节b[off]先写,然后字节b[off + 1]等等。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。 实施者可以使用flushBits的方法ImageOutputStreamImpl保证这一点。
write在接口
DataOutput
write在接口
ImageOutputStream
write在
ImageOutputStreamImpl
b - 要写入的
byte的数组。
off - 数据中的起始偏移量。
len -数量
byte s到写。
IOException - 如果发生I / O错误。
public long length()
ImageInputStreamImpl
-1L以表示该流具有未知长度。
子类必须覆盖此方法以提供实际的长度信息。
length在接口
ImageInputStream
length在
ImageInputStreamImpl
public void seek(long pos)
throws IOException
EOFException会,如果执行读取只抛出。
在执行写入之前,文件长度不会增加。
seek在接口
ImageInputStream
seek在
ImageInputStreamImpl
pos - 一个
long所需文件指针位置的long。
IndexOutOfBoundsException - 如果
pos小于冲洗位置。
IOException - 如果发生任何其他I / O错误。
public void close()
throws IOException
ImageInputStream复制
IOException或错误的行为。
调用此方法可能允许实现此接口的类释放与流相关的资源,如内存,磁盘空间或文件描述符。
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.