本文整理了Java中org.apache.commons.compress.utils.IOUtils.skip()
方法的一些代码示例,展示了IOUtils.skip()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.skip()
方法的具体详情如下:
包路径:org.apache.commons.compress.utils.IOUtils
类名称:IOUtils
方法名:skip
[英]Skips the given number of bytes by repeatedly invoking skip on the given input stream if necessary.
In a case where the stream's skip() method returns 0 before the requested number of bytes has been skip this implementation will fall back to using the read() method.
This method will only skip less than the requested number of bytes if the end of the input stream has been reached.
[中]如果需要,通过在给定的输入流上重复调用skip来跳过给定的字节数。
如果流的skip()方法在请求的字节数被跳过之前返回0,则此实现将退回到使用read()方法。
如果到达输入流的末尾,此方法将只跳过小于请求字节数的字节。
代码示例来源:origin: org.apache.commons/commons-compress
/** {@inheritDoc} */
@Override
public long skip(final long n) throws IOException {
return IOUtils.skip(in, n);
}
代码示例来源:origin: org.apache.commons/commons-compress
@Override
public long skip(final long n) throws IOException {
return IOUtils.skip(decIS, n);
}
代码示例来源:origin: org.apache.commons/commons-compress
/** {@inheritDoc} */
@Override
public long skip(final long n) throws IOException {
return IOUtils.skip(in, n);
}
代码示例来源:origin: org.apache.commons/commons-compress
@Override
public long skip(final long n) throws IOException {
return IOUtils.skip(decIS, n);
}
代码示例来源:origin: org.apache.commons/commons-compress
@Override
public long skip(final long n) throws IOException {
final long toSkip = max >= 0 ? Math.min(n, max - pos) : n;
final long skippedBytes = IOUtils.skip(in, toSkip);
pos += skippedBytes;
return skippedBytes;
}
代码示例来源:origin: org.apache.commons/commons-compress
@Override
public long skip(final long count) throws IOException {
return IOUtils.skip(streamBridge.getInput(), count);
}
代码示例来源:origin: org.apache.commons/commons-compress
private InputStream getCurrentStream() throws IOException {
if (archive.files[currentEntryIndex].getSize() == 0) {
return new ByteArrayInputStream(new byte[0]);
}
if (deferredBlockStreams.isEmpty()) {
throw new IllegalStateException("No current 7z entry (call getNextEntry() first).");
}
while (deferredBlockStreams.size() > 1) {
// In solid compression mode we need to decompress all leading folder'
// streams to get access to an entry. We defer this until really needed
// so that entire blocks can be skipped without wasting time for decompression.
try (final InputStream stream = deferredBlockStreams.remove(0)) {
IOUtils.skip(stream, Long.MAX_VALUE);
}
compressedBytesReadFromCurrentEntry = 0;
}
return deferredBlockStreams.get(0);
}
代码示例来源:origin: org.apache.commons/commons-compress
private void skipBlock() throws IOException {
final int size = readSize();
final long read = IOUtils.skip(in, size);
count(read);
if (read != size) {
throw new IOException("premature end of stream");
}
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* This method is invoked once the end of the archive is hit, it
* tries to consume the remaining bytes under the assumption that
* the tool creating this archive has padded the last block.
*/
private void consumeRemainderOfLastBlock() throws IOException {
final long bytesReadOfLastBlock = getBytesRead() % blockSize;
if (bytesReadOfLastBlock > 0) {
final long skipped = IOUtils.skip(is, blockSize - bytesReadOfLastBlock);
count(skipped);
}
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* The last record block should be written at the full size, so skip any
* additional space used to fill a record after an entry
*/
private void skipRecordPadding() throws IOException {
if (!isDirectory() && this.entrySize > 0 && this.entrySize % this.recordSize != 0) {
final long numRecords = (this.entrySize / this.recordSize) + 1;
final long padding = (numRecords * this.recordSize) - this.entrySize;
final long skipped = IOUtils.skip(is, padding);
count(skipped);
}
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Skips over and discards <code>n</code> bytes of data from this input
* stream. The <code>skip</code> method may, for a variety of reasons, end
* up skipping over some smaller number of bytes, possibly <code>0</code>.
* This may result from any of a number of conditions; reaching end of file
* or end of entry before <code>n</code> bytes have been skipped; are only
* two possibilities. The actual number of bytes skipped is returned. If
* <code>n</code> is negative, no bytes are skipped.
*
*
* @param n
* the number of bytes to be skipped.
* @return the actual number of bytes skipped.
* @throws IOException
* if some other I/O error occurs.
*/
@Override
public long skip(final long n) throws IOException {
if (n <= 0 || isDirectory()) {
return 0;
}
final long available = entrySize - entryOffset;
final long skipped = IOUtils.skip(is, Math.min(n, available));
count(skipped);
entryOffset += skipped;
return skipped;
}
代码示例来源:origin: org.apache.commons/commons-compress
@Override
public long skip(final long n) throws IOException {
try {
return IOUtils.skip(in, n);
} catch (org.tukaani.xz.MemoryLimitException e) {
//convert to commons-compress MemoryLimtException
throw new MemoryLimitException(e.getMemoryNeeded(), e.getMemoryLimit(), e);
}
}
代码示例来源:origin: org.apache.commons/commons-compress
if (IOUtils.skip(in, skipAmount) != skipAmount) {
throw new IOException();
代码示例来源:origin: org.apache.commons/commons-compress
@Override
public ArjArchiveEntry getNextEntry() throws IOException {
if (currentInputStream != null) {
// return value ignored as IOUtils.skip ensures the stream is drained completely
IOUtils.skip(currentInputStream, Long.MAX_VALUE);
currentInputStream.close();
currentLocalFileHeader = null;
currentInputStream = null;
}
currentLocalFileHeader = readLocalFileHeader();
if (currentLocalFileHeader != null) {
currentInputStream = new BoundedInputStream(in, currentLocalFileHeader.compressedSize);
if (currentLocalFileHeader.method == LocalFileHeader.Methods.STORED) {
currentInputStream = new CRC32VerifyingInputStream(currentInputStream,
currentLocalFileHeader.originalSize, currentLocalFileHeader.originalCrc32);
}
return new ArjArchiveEntry(currentLocalFileHeader);
}
currentInputStream = null;
return null;
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Skips over the contents of a skippable frame as well as
* skippable frames following it.
*
* <p>It then tries to read four more bytes which are supposed to
* hold an LZ4 signature and returns the number of bytes read
* while storing the bytes in the given array.</p>
*/
private int skipSkippableFrame(byte[] b) throws IOException {
int read = 4;
while (read == 4 && isSkippableFrameSignature(b)) {
long len = ByteUtils.fromLittleEndian(supplier, 4);
long skipped = IOUtils.skip(in, len);
count(skipped);
if (len != skipped) {
throw new IOException("Premature end of stream while skipping frame");
}
read = IOUtils.readFully(in, b);
count(read);
}
return read;
}
代码示例来源:origin: org.apache.commons/commons-compress
if (currentEntry != null) {
final long entryEnd = entryOffset + currentEntry.getLength();
long skipped = IOUtils.skip(input, entryEnd - offset);
trackReadBytes(skipped);
currentEntry = null;
代码示例来源:origin: org.apache.commons/commons-compress
IOUtils.skip(this, Long.MAX_VALUE);
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
private void skipBlock() throws IOException {
final int size = readSize();
final long read = IOUtils.skip(in, size);
count(read);
if (read != size) {
throw new IOException("premature end of stream");
}
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/**
* This method is invoked once the end of the archive is hit, it
* tries to consume the remaining bytes under the assumption that
* the tool creating this archive has padded the last block.
*/
private void consumeRemainderOfLastBlock() throws IOException {
final long bytesReadOfLastBlock = getBytesRead() % blockSize;
if (bytesReadOfLastBlock > 0) {
final long skipped = IOUtils.skip(is, blockSize - bytesReadOfLastBlock);
count(skipped);
}
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/**
* The last record block should be written at the full size, so skip any
* additional space used to fill a record after an entry
*/
private void skipRecordPadding() throws IOException {
if (!isDirectory() && this.entrySize > 0 && this.entrySize % this.recordSize != 0) {
final long numRecords = (this.entrySize / this.recordSize) + 1;
final long padding = (numRecords * this.recordSize) - this.entrySize;
final long skipped = IOUtils.skip(is, padding);
count(skipped);
}
}
内容来源于网络,如有侵权,请联系作者删除!