类 ResettableInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- com.tencent.cos.xml.crypto.SdkFilterInputStream
-
- com.tencent.cos.xml.crypto.ReleasableInputStream
-
- com.tencent.cos.xml.crypto.ResettableInputStream
-
- 所有已实现的接口:
Releasable,java.io.Closeable,java.lang.AutoCloseable
public class ResettableInputStream extends ReleasableInputStream
A mark-and-resettable input stream that can be used on files or file input streams. In particular, aResettableInputStreamallows the close operation to be disabled viaReleasableInputStream.disableClose()(to avoid accidentally being closed). This is necessary when such input stream needs to be marked-and-reset multiple times but only as long as the stream has not been closed.The creator of this input stream should therefore always call
ReleasableInputStream.release()in a finally block to truly release the underlying resources.- 另请参阅:
Releasable
-
-
构造器概要
构造器 构造器 说明 ResettableInputStream(java.io.File file)ResettableInputStream(java.io.FileInputStream fis)ResettableInputStream(java.lang.String filePath)
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 intavailable()java.io.FilegetFile()Returns the underlying file, if known; or null if not;voidmark(int limit)Marks the current position in this input stream.booleanmarkSupported()static ResettableInputStreamnewResettableInputStream(java.io.File file)Convenient factory method to construct a new resettable input stream for the given file, converting any IOException into CosClientException.static ResettableInputStreamnewResettableInputStream(java.io.FileInputStream fis)Convenient factory method to construct a new resettable input stream for the given file input stream, converting any IOException into CosClientException.static ResettableInputStreamnewResettableInputStream(java.io.FileInputStream fis, java.lang.String errmsg)Convenient factory method to construct a new resettable input stream for the given file input stream, converting any IOException into CosClientException with the given error message.static ResettableInputStreamnewResettableInputStream(java.io.File file, java.lang.String errmsg)Convenient factory method to construct a new resettable input stream for the given file, converting any IOException into CosClientException with the given error message.intread()intread(byte[] arg0, int arg1, int arg2)voidreset()Repositions this stream to the position at the time themarkmethod was last called on this input stream.longskip(long n)-
从类继承的方法 com.tencent.cos.xml.crypto.ReleasableInputStream
close, disableClose, isCloseDisabled, release, wrap
-
从类继承的方法 com.tencent.cos.xml.crypto.SdkFilterInputStream
abort, abortIfNeeded, isAborted
-
-
-
-
构造器详细资料
-
ResettableInputStream
public ResettableInputStream(java.io.File file) throws java.io.IOException- 参数:
file- must not be null. Upon successful construction the the file will be opened with an input stream automatically marked at the starting position of the given file.Note the creation of a
ResettableInputStreamwould entail physically opening a file. If the opened file is meant to be closed only (in a finally block) by the very same code block that created it, then it is necessary that the release method must not be called while the execution is made in other stack frames. In such case, as other stack frames may inadvertently or indirectly call the close method of the stream, the creator of the stream would need to explicitly disable the accidental closing viaReleasableInputStream.disableClose(), so that the release method becomes the only way to truly close the opened file.- 抛出:
java.io.IOException
-
ResettableInputStream
public ResettableInputStream(java.lang.String filePath) throws java.io.IOException- 抛出:
java.io.IOException
-
ResettableInputStream
public ResettableInputStream(java.io.FileInputStream fis) throws java.io.IOException- 参数:
fis- file input stream; must not be null. Upon successful construction the input stream will be automatically marked at the current position of the given file input stream.Note the creation of a
ResettableInputStreamwould entail physically opening a file. If the opened file is meant to be closed only (in a finally block) by the very same code block that created it, then it is necessary that the release method must not be called while the execution is made in other stack frames. In such case, as other stack frames may inadvertently or indirectly call the close method of the stream, the creator of the stream would need to explicitly disable the accidental closing viaReleasableInputStream.disableClose(), so that the release method becomes the only way to truly close the opened file.- 抛出:
java.io.IOException
-
-
方法详细资料
-
markSupported
public final boolean markSupported()
- 覆盖:
markSupported在类中SdkFilterInputStream
-
mark
public void mark(int limit)
Marks the current position in this input stream. A subsequent call to theresetmethod repositions this stream at the last marked position so that subsequent reads re-read the same bytes. This method works as long as the underlying file has not been closed.Note the creation of a
ResettableInputStreamwould entail physically opening a file. If the opened file is meant to be closed only (in a finally block) by the very same code block that created it, then it is necessary that the release method must not be called while the execution is made in other stack frames.In such case, as other stack frames may inadvertently or indirectly call the close method of the stream, the creator of the stream would need to explicitly disable the accidental closing via
ReleasableInputStream.disableClose(), so that the release method becomes the only way to truly close the opened file.- 覆盖:
mark在类中SdkFilterInputStream- 参数:
limit- limit
-
reset
public void reset() throws java.io.IOExceptionRepositions this stream to the position at the time themarkmethod was last called on this input stream. This method works as long as the underlying file has not been closed.Note the creation of a
ResettableInputStreamwould entail physically opening a file. If the opened file is meant to be closed only (in a finally block) by the very same code block that created it, then it is necessary that the release method must not be called while the execution is made in other stack frames. In such case, as other stack frames may inadvertently or indirectly call the close method of the stream, the creator of the stream would need to explicitly disable the accidental closing viaReleasableInputStream.disableClose(), so that the release method becomes the only way to truly close the opened file.- 覆盖:
reset在类中SdkFilterInputStream- 抛出:
java.io.IOException
-
available
public int available() throws java.io.IOException- 覆盖:
available在类中SdkFilterInputStream- 抛出:
java.io.IOException
-
read
public int read() throws java.io.IOException- 覆盖:
read在类中SdkFilterInputStream- 抛出:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- 覆盖:
skip在类中SdkFilterInputStream- 抛出:
java.io.IOException
-
read
public int read(byte[] arg0, int arg1, int arg2) throws java.io.IOException- 覆盖:
read在类中SdkFilterInputStream- 抛出:
java.io.IOException
-
getFile
public java.io.File getFile()
Returns the underlying file, if known; or null if not;
-
newResettableInputStream
public static ResettableInputStream newResettableInputStream(java.io.File file)
Convenient factory method to construct a new resettable input stream for the given file, converting any IOException into CosClientException.Note the creation of a
ResettableInputStreamwould entail physically opening a file. If the opened file is meant to be closed only (in a finally block) by the very same code block that created it, then it is necessary that the release method must not be called while the execution is made in other stack frames. In such case, as other stack frames may inadvertently or indirectly call the close method of the stream, the creator of the stream would need to explicitly disable the accidental closing viaReleasableInputStream.disableClose(), so that the release method becomes the only way to truly close the opened file.
-
newResettableInputStream
public static ResettableInputStream newResettableInputStream(java.io.File file, java.lang.String errmsg)
Convenient factory method to construct a new resettable input stream for the given file, converting any IOException into CosClientException with the given error message.Note the creation of a
ResettableInputStreamwould entail physically opening a file. If the opened file is meant to be closed only (in a finally block) by the very same code block that created it, then it is necessary that the release method must not be called while the execution is made in other stack frames. In such case, as other stack frames may inadvertently or indirectly call the close method of the stream, the creator of the stream would need to explicitly disable the accidental closing viaReleasableInputStream.disableClose(), so that the release method becomes the only way to truly close the opened file.
-
newResettableInputStream
public static ResettableInputStream newResettableInputStream(java.io.FileInputStream fis)
Convenient factory method to construct a new resettable input stream for the given file input stream, converting any IOException into CosClientException.Note the creation of a
ResettableInputStreamwould entail physically opening a file. If the opened file is meant to be closed only (in a finally block) by the very same code block that created it, then it is necessary that the release method must not be called while the execution is made in other stack frames. In such case, as other stack frames may inadvertently or indirectly call the close method of the stream, the creator of the stream would need to explicitly disable the accidental closing viaReleasableInputStream.disableClose(), so that the release method becomes the only way to truly close the opened file.
-
newResettableInputStream
public static ResettableInputStream newResettableInputStream(java.io.FileInputStream fis, java.lang.String errmsg)
Convenient factory method to construct a new resettable input stream for the given file input stream, converting any IOException into CosClientException with the given error message.Note the creation of a
ResettableInputStreamwould entail physically opening a file. If the opened file is meant to be closed only (in a finally block) by the very same code block that created it, then it is necessary that the release method must not be called while the execution is made in other stack frames. In such case, as other stack frames may inadvertently or indirectly call the close method of the stream, the creator of the stream would need to explicitly disable the accidental closing viaReleasableInputStream.disableClose(), so that the release method becomes the only way to truly close the opened file.
-
-