本文整理汇总了Java中org.apache.commons.io.input.BoundedInputStream.setPropagateClose方法的典型用法代码示例。如果您正苦于以下问题:Java BoundedInputStream.setPropagateClose方法的具体用法?Java BoundedInputStream.setPropagateClose怎么用?Java BoundedInputStream.setPropagateClose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.input.BoundedInputStream
的用法示例。
在下文中一共展示了BoundedInputStream.setPropagateClose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDownloadersInputStream
import org.apache.commons.io.input.BoundedInputStream; //导入方法依赖的package包/类
@Override
protected InputStream getDownloadersInputStream() throws IOException {
Request request = Request.createGET(sourcePath, connection);
Response response = request.send();
fileDetails = response.toFileDetails();
// TODO: Manage the dependency which includes this class better?
// Right now, I only needed the one class from apache commons.
// There are countless classes online which provide this functionality,
// including some which are available from the Android SDK - the only
// problem is that they have a funky API which doesn't just wrap a
// plain old InputStream (the class is ContentLengthInputStream -
// whereas this BoundedInputStream is much more generic and useful
// to us).
BoundedInputStream stream = new BoundedInputStream(response.toContentStream(), fileDetails.getFileSize());
stream.setPropagateClose(false);
return stream;
}
示例2: read
import org.apache.commons.io.input.BoundedInputStream; //导入方法依赖的package包/类
@Override
public Object read(Kryo kryo, Input input, Class type) {
//First item to read is an integer representing the length of the written byte array
int lDOMLength = input.readInt();
//Restrict the InputStream to be read to the length of the serialised DOM, so the DOM constructor doesn't deplete the raw Kryo InputStream
BoundedInputStream lBoundedInputStream = new BoundedInputStream(input, lDOMLength);
//Don't allow close calls from the XML deserialiser to propogate to the wrapped InputStream
lBoundedInputStream.setPropagateClose(false);
return DOM.createDocument(lBoundedInputStream, false);
}
示例3: boundedInputStream
import org.apache.commons.io.input.BoundedInputStream; //导入方法依赖的package包/类
BoundedInputStream boundedInputStream(InputStream inputStream, int length) {
BoundedInputStream bis = new BoundedInputStream(inputStream, length); // No close() required/ not propagated.
bis.setPropagateClose(false);
return bis;
}