Examples of BoundedInputStream


Examples of org.apache.commons.compress.utils.BoundedInputStream

    }
   
    private void buildDecodingStream() throws IOException {
        final int folderIndex = archive.streamMap.fileFolderIndex[currentEntryIndex];
        if (folderIndex < 0) {
            currentEntryInputStream = new BoundedInputStream(
                    new ByteArrayInputStream(new byte[0]), 0);
            return;
        }
        if (currentFolderIndex == folderIndex) {
            // need to advance the folder input stream past the current file
            drainPreviousEntry();
        } else {
            currentFolderIndex = folderIndex;
            if (currentFolderInputStream != null) {
                currentFolderInputStream.close();
                currentFolderInputStream = null;
            }
           
            final Folder folder = archive.folders[folderIndex];
            final int firstPackStreamIndex = archive.streamMap.folderFirstPackStreamIndex[folderIndex];
            final long folderOffset = SIGNATURE_HEADER_SIZE + archive.packPos +
                    archive.streamMap.packStreamOffsets[firstPackStreamIndex];
            currentFolderInputStream = buildDecoderStack(folder, folderOffset, firstPackStreamIndex);
        }
        final SevenZArchiveEntry file = archive.files[currentEntryIndex];
        final InputStream fileStream = new BoundedInputStream(
                currentFolderInputStream, file.getSize());
        if (file.getHasCrc()) {
            currentEntryInputStream = new CRC32VerifyingInputStream(
                    fileStream, file.getSize(), file.getCrc());
        } else {
View Full Code Here

Examples of org.apache.commons.compress.utils.BoundedInputStream

            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);
View Full Code Here

Examples of org.apache.commons.compress.utils.BoundedInputStream

            expectedChecksum = unmask(readCrc());
        } else if (type == COMPRESSED_CHUNK_TYPE) {
            long size = readSize() - 4 /* CRC */;
            expectedChecksum = unmask(readCrc());
            currentCompressedChunk =
                new SnappyCompressorInputStream(new BoundedInputStream(in, size));
            // constructor reads uncompressed size
            count(currentCompressedChunk.getBytesRead());
        } else {
            // impossible as all potential byte values have been covered
            throw new IOException("unknown chunk type " + type
View Full Code Here

Examples of org.apache.commons.compress.utils.BoundedInputStream

        ZipArchiveEntry entry = zin.getNextZipEntry();
        assertEquals("entry name", entryName, entry.getName());
        assertTrue("entry can't be read", zin.canReadEntryData(entry));
        assertEquals("method", ZipMethod.IMPLODING.getCode(), entry.getMethod());

        InputStream bio = new BoundedInputStream(zin, entry.getSize());
       
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        CheckedOutputStream out = new CheckedOutputStream(bout, new CRC32());
        IOUtils.copy(bio, out);
View Full Code Here

Examples of org.apache.commons.compress.utils.BoundedInputStream

            expectedChecksum = unmask(readCrc());
        } else if (type == COMPRESSED_CHUNK_TYPE) {
            long size = readSize() - 4 /* CRC */;
            expectedChecksum = unmask(readCrc());
            currentCompressedChunk =
                new SnappyCompressorInputStream(new BoundedInputStream(in, size));
            // constructor reads uncompressed size
            count(currentCompressedChunk.getBytesRead());
        } else {
            // impossible as all potential byte values have been covered
            throw new IOException("unknown chunk type " + type
View Full Code Here

Examples of org.apache.commons.compress.utils.BoundedInputStream

            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);
View Full Code Here

Examples of org.apache.commons.compress.utils.BoundedInputStream

    }
   
    private void buildDecodingStream() throws IOException {
        final int folderIndex = archive.streamMap.fileFolderIndex[currentEntryIndex];
        if (folderIndex < 0) {
            currentEntryInputStream = new BoundedInputStream(
                    new ByteArrayInputStream(new byte[0]), 0);
            return;
        }
        if (currentFolderIndex == folderIndex) {
            // need to advance the folder input stream past the current file
            drainPreviousEntry();
        } else {
            currentFolderIndex = folderIndex;
            if (currentFolderInputStream != null) {
                currentFolderInputStream.close();
                currentFolderInputStream = null;
            }
           
            final Folder folder = archive.folders[folderIndex];
            final int firstPackStreamIndex = archive.streamMap.folderFirstPackStreamIndex[folderIndex];
            final long folderOffset = SIGNATURE_HEADER_SIZE + archive.packPos +
                    archive.streamMap.packStreamOffsets[firstPackStreamIndex];
            currentFolderInputStream = buildDecoderStack(folder, folderOffset, firstPackStreamIndex);
        }
        final SevenZArchiveEntry file = archive.files[currentEntryIndex];
        final InputStream fileStream = new BoundedInputStream(
                currentFolderInputStream, file.getSize());
        if (file.getHasCrc()) {
            currentEntryInputStream = new CRC32VerifyingInputStream(
                    fileStream, file.getSize(), file.getCrcValue());
        } else {
View Full Code Here

Examples of org.apache.commons.io.input.BoundedInputStream

            long length = randomAccessFile.length() - header.getMp3StartByte();
            if (new String(tag).equals("TAG")) {
                length -= 128;
            }
            randomAccessFile.seek(header.getMp3StartByte());
            InputStream is = new BoundedInputStream(new RandomAccessFileInputstream(randomAccessFile), length);
            MessageDigest m = MessageDigest.getInstance("MD5");
            byte[] buffer = new byte[8192];
            int read;
            while ((read = is.read(buffer)) > 0) {
                m.update(buffer, 0, read);
            }
            randomAccessFile.close();
            return new BigInteger(1, m.digest()).toString(16) + String.format("-%08x", length);
        } catch (TagException e) {
View Full Code Here

Examples of org.apache.commons.io.input.BoundedInputStream

      final long streamlength = Long.parseLong(cl);
      fileLength = startPos + streamlength;

      // Java has a bug with >2GB request streams.  It won't bounds check
      // the reads so the transfer blocks until the server times out
      in = new BoundedInputStream(in, streamlength);
    }

    return in;
  }
View Full Code Here

Examples of org.apache.commons.io.input.BoundedInputStream

        writer.write(fileType);
        writer.write("\nLogLength:");
        writer.write(fileLengthStr);
        writer.write("\nLog Contents:\n");
        // ByteLevel
        BoundedInputStream bis =
            new BoundedInputStream(valueStream, fileLength);
        InputStreamReader reader = new InputStreamReader(bis);
        int currentRead = 0;
        int totalRead = 0;
        while ((currentRead = reader.read(cbuf, 0, bufferSize)) != -1) {
          writer.write(cbuf);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.