public class FileCacheImageOutputStream extends ImageOutputStreamImpl
ImageOutputStream
写入输出到正规的
OutputStream
实现。一个文件用于缓存数据,直到它被刷新到输出流为止。
bitOffset, byteOrder, flushedPos, streamPos
Constructor and Description |
---|
FileCacheImageOutputStream(OutputStream stream, File cacheDir)
构建了一个
FileCacheImageOutputStream 会写指定的
outputStream 。
|
Modifier and Type | Method and Description |
---|---|
void |
close()
关闭
FileCacheImageOutputStream 。
|
void |
flushBefore(long pos)
其流的初始部分所指示的位置之前。
|
boolean |
isCached()
返回
true 因为这
ImageOutputStream 缓存数据以便寻求向后。
|
boolean |
isCachedFile()
返回
true 因为这
ImageOutputStream 保持文件缓存。
|
boolean |
isCachedMemory()
返回
false 因为这
ImageOutputStream 不保持内存缓存。
|
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, writeUTF
checkClosed, finalize, 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, setBitOffset, setByteOrder, skipBytes, skipBytes
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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, setBitOffset, setByteOrder, skipBytes, skipBytes
public FileCacheImageOutputStream(OutputStream stream, File cacheDir) throws IOException
FileCacheImageOutputStream
会写指定的
outputStream
。
一个临时文件被用作缓存。如果cacheDir
is non-null
是目录,文件将被创建在。如果是null
,依赖于系统默认的临时文件目录将被使用(见File.createTempFile
详情的文件)。
stream
-
OutputStream
写。
cacheDir
-
File
标明缓存文件应该被创建,或
null
使用系统目录。
null
stream
IllegalArgumentException
。
IllegalArgumentException
-如果
cacheDir
是非
null
但不是目录。
IOException
-如果一个缓存文件无法创建。
public int read() throws IOException
ImageInputStreamImpl
int
。如果达到
-1
返回EOF。
子类必须为这种方法提供一个实现。子类实现应在退出之前更新流位置。
在流中的位偏移量必须在读取发生之前重置为零。
read
接口
ImageInputStream
read
方法重写,继承类
ImageInputStreamImpl
-1
EOF。
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。实施者可以使用的方法来保证这ImageOutputStreamImpl
flushBits
。
write
接口
DataOutput
write
接口
ImageOutputStream
write
方法重写,继承类
ImageOutputStreamImpl
b
-
int
的低8位都要写。
IOException
如果I/O错误发生。
public void write(byte[] b, int off, int len) throws IOException
ImageOutputStream
len
是0,什么都不写。字节
b[off]
是第一次写,然后
b[off + 1]
字节,等等。
如果在流偏位非零,其余的当前字节填充0和写了第一。写入后的位偏移量将为0。实施者可以使用的方法来保证这ImageOutputStreamImpl
flushBits
。
write
接口
DataOutput
write
接口
ImageOutputStream
write
方法重写,继承类
ImageOutputStreamImpl
b
-
byte
s被写入数组。
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
含有所需的文件指针的位置。
IndexOutOfBoundsException
-如果
pos
小于刷新位置。
IOException
-如果任何其他发生I/O错误。
public boolean isCached()
true
因为这
ImageOutputStream
缓存数据以便寻求向后。
isCached
接口
ImageInputStream
isCached
方法重写,继承类
ImageInputStreamImpl
true
。
isCachedMemory()
,
isCachedFile()
public boolean isCachedFile()
true
因为这
ImageOutputStream
保持文件缓存。
isCachedFile
接口
ImageInputStream
isCachedFile
方法重写,继承类
ImageInputStreamImpl
true
。
isCached()
,
isCachedMemory()
public boolean isCachedMemory()
false
因为这
ImageOutputStream
不保持内存缓存。
isCachedMemory
接口
ImageInputStream
isCachedMemory
方法重写,继承类
ImageInputStreamImpl
false
。
isCached()
,
isCachedFile()
public void close() throws IOException
FileCacheImageOutputStream
。所有挂起的数据刷新到输出,并关闭和删除缓存文件。目的
OutputStream
不是封闭的。
close
接口
Closeable
close
接口
AutoCloseable
close
接口
ImageInputStream
close
方法重写,继承类
ImageInputStreamImpl
IOException
-如果出现错误。
public void flushBefore(long pos) throws IOException
ImageInputStream
IndexOutOfBoundsException
。
打电话flushBefore
允许实现了这个接口的类来释放资源如内存或磁盘空间被用来存储数据流。
flushBefore
接口
ImageInputStream
flushBefore
接口
ImageOutputStream
flushBefore
方法重写,继承类
ImageInputStreamImpl
pos
-
long
含流前缀可能冲长度。
IOException
如果I/O错误发生。
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.