本文整理汇总了Java中org.hsqldb.lib.InputStreamWrapper.available方法的典型用法代码示例。如果您正苦于以下问题:Java InputStreamWrapper.available方法的具体用法?Java InputStreamWrapper.available怎么用?Java InputStreamWrapper.available使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hsqldb.lib.InputStreamWrapper
的用法示例。
在下文中一共展示了InputStreamWrapper.available方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TarEntrySupplicant
import org.hsqldb.lib.InputStreamWrapper; //导入方法依赖的package包/类
/**
* After instantiating a TarEntrySupplicant, the user must either invoke
* write() or close(), to release system resources on the input
* File/Stream.
* <P>
* <B>WARNING:</B>
* Do not use this method unless the quantity of available RAM is
* sufficient to accommodate the specified maxBytes all at one time.
* This constructor loads all input from the specified InputStream into
* RAM before anything is written to disk.
* </P>
*
* @param maxBytes This method will fail if more than maxBytes bytes
* are supplied on the specified InputStream.
* As the type of this parameter enforces, the max
* size you can request is 2GB.
*/
public TarEntrySupplicant(String path, InputStream origStream,
int maxBytes, char typeFlag,
TarFileOutputStream tarStream)
throws IOException, TarMalformatException {
/*
* If you modify this, make sure to not intermix reading/writing of
* the PipedInputStream and the PipedOutputStream, or you could
* cause dead-lock. Everything is safe if you close the
* PipedOutputStream before reading the PipedInputStream.
*/
this(path, typeFlag, tarStream, 0100000000000L);
if (maxBytes < 1) {
throw new IllegalArgumentException(RB.read_lt_1.getString());
}
int i;
PipedOutputStream outPipe = new PipedOutputStream();
/*
* This constructor not available until Java 1.6:
* inputStream = new PipedInputStream(outPipe, maxBytes);
*/
try {
inputStream =
new InputStreamWrapper(new PipedInputStream(outPipe));
while ((i =
origStream.read(tarStream.writeBuffer, 0,
tarStream.writeBuffer.length)) > 0) {
outPipe.write(tarStream.writeBuffer, 0, i);
}
outPipe.flush(); // Do any good on a pipe?
dataSize = inputStream.available();
if (TarFileOutputStream.debug) {
System.out.println(
RB.stream_buffer_report.getString(
Long.toString(dataSize)));
}
} catch (IOException ioe) {
close();
throw ioe;
} finally {
try {
outPipe.close();
} finally {
outPipe = null; // Encourage buffer GC
}
}
modTime = new java.util.Date().getTime() / 1000L;
}