Examples of CountingInputStream


Examples of de.undercouch.bson4jackson.io.CountingInputStream

      //their methods are synchronized. Our StaticBufferedInputStream
      //is not thread-safe and thus much faster.
      if (!(in instanceof UnsafeByteArrayInputStream)) {
        in = new StaticBufferedInputStream(in);
      }
      _counter = new CountingInputStream(in);
      _in = new LittleEndianInputStream(_counter);
    }
  }
View Full Code Here

Examples of net.sf.cram.io.CountingInputStream

            params.cramFile), pass, 1, 128);
      }
    }

    long offset = 0;
    CountingInputStream cis = new CountingInputStream(is);
    CramHeader cramHeader = ReadWrite.readCramHeader(cis);
    offset = cis.getCount();

    SAMFileWriterFactory samFileWriterFactory = new SAMFileWriterFactory();
    samFileWriterFactory.setAsyncOutputBufferSize(10000);
    samFileWriterFactory.setCreateIndex(false);
    samFileWriterFactory.setCreateMd5File(false);
View Full Code Here

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

        ArchiveInputStream archiveInputStream = null;
        ArchiveEntry entry;
        try {

            final CountingInputStream inputStream = new CountingInputStream(new FileInputStream(inputArchive));

            final long inputFileSize = inputArchive.length();

            if(inputArchive.getName().endsWith(".tbz2")) {
                archiveInputStream = new TarArchiveInputStream(
                        new BZip2CompressorInputStream(inputStream));
            } else {
                archiveInputStream = new ArchiveStreamFactory().createArchiveInputStream(
                        new BufferedInputStream(inputStream));
            }

            final ProgressBar progressBar = new ProgressBar(inputFileSize);
            while ((entry = archiveInputStream.getNextEntry()) != null) {
                final File outputFile = new File(targetDirectory, entry.getName());

                // Entry is a directory.
                if (entry.isDirectory()) {
                    if (!outputFile.exists()) {
                        if(!outputFile.mkdirs()) {
                            throw new RetrieverException(
                                    "Could not create output directory " + outputFile.getAbsolutePath());
                        }
                    }
                }

                // Entry is a file.
                else {
                    final byte[] data = new byte[BUFFER_MAX];
                    final FileOutputStream fos = new FileOutputStream(outputFile);
                    BufferedOutputStream dest = null;
                    try {
                        dest = new BufferedOutputStream(fos, BUFFER_MAX);

                        int count;
                        while ((count = archiveInputStream.read(data, 0, BUFFER_MAX)) != -1) {
                            dest.write(data, 0, count);
                            progressBar.updateProgress(inputStream.getBytesRead());
                        }
                    } finally {
                        if(dest != null) {
                            dest.flush();
                            dest.close();
                        }
                    }
                }

                progressBar.updateProgress(inputStream.getBytesRead());
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
View Full Code Here

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

            // Request sent. Now get the response:
            InputStream instream = httpMethod.getResponseBodyAsStream();

            if (instream != null) {// will be null for HEAD
                instream = new CountingInputStream(instream);
                try {
                    Header responseHeader = httpMethod.getResponseHeader(HEADER_CONTENT_ENCODING);
                    if (responseHeader!= null && ENCODING_GZIP.equals(responseHeader.getValue())) {
                        InputStream tmpInput = new GZIPInputStream(instream); // tmp inputstream needs to have a good counting
                        res.setResponseData(readResponse(res, tmpInput, (int) httpMethod.getResponseContentLength()));                       
View Full Code Here

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

        // works OK even if ContentEncoding is null
        boolean gzipped = ENCODING_GZIP.equals(conn.getContentEncoding());
        InputStream instream = null;
        try {
            instream = new CountingInputStream(conn.getInputStream());
            if (gzipped) {
                in = new BufferedInputStream(new GZIPInputStream(instream));
            } else {
                in = new BufferedInputStream(instream);
            }
View Full Code Here

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

        private boolean sawEof;

        Reader(InputStream input) throws IOException {
            assert input != null;
            this.counter = new CountingInputStream(input);
            this.input = new ZipInputStream(counter);
            ZipEntry first = this.input.getNextEntry();
            if (first == null || first.getName().equals(FIRST_ENTRY_NAME) == false) {
                throw new IOException("file list is broken");
            }
View Full Code Here

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

//
//        return omDocument;
//    }

    public void testBuild() throws Exception {
        CountingInputStream in = new CountingInputStream(getTestResource(
                TestConstants.REALLY_BIG_MESSAGE));
        OMDocument doc = OMXMLBuilderFactory.createOMBuilder(omMetaFactory.getOMFactory(), in).getDocument();
        assertFalse(doc.isComplete());
        int countBeforeBuild = in.getCount();
        doc.build();
        assertTrue(doc.isComplete());
        int countAfterBuild = in.getCount();
        assertTrue(countAfterBuild > countBeforeBuild);
        OMNode node = doc.getFirstOMChild();
        while (node != null) {
            node = node.getNextOMSibling();
        }
        assertEquals(countAfterBuild, in.getCount());
    }
View Full Code Here

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

                    rs = null;
                }
            }
            MessageDigest digest = getDigest();
            DigestInputStream dIn = new DigestInputStream(stream, digest);
            CountingInputStream in = new CountingInputStream(dIn);
            StreamWrapper wrapper;
            if (STORE_SIZE_MINUS_ONE.equals(storeStream)) {
                wrapper = new StreamWrapper(in, -1);
            } else if (STORE_SIZE_MAX.equals(storeStream)) {
                wrapper = new StreamWrapper(in, Integer.MAX_VALUE);
            } else if (STORE_TEMP_FILE.equals(storeStream)) {
                File temp = moveToTempFile(in);
                long length = temp.length();
                wrapper = new StreamWrapper(new TempFileInputStream(temp, true), length);
            } else {
                throw new DataStoreException("Unsupported stream store algorithm: " + storeStream);
            }
            // UPDATE DATASTORE SET DATA=? WHERE ID=?
            conHelper.exec(updateDataSQL, wrapper, tempId);
            long length = in.getByteCount();
            DataIdentifier identifier = new DataIdentifier(digest.digest());
            usesIdentifier(identifier);
            String id = identifier.toString();
            long newModified;
            while (true) {
View Full Code Here

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

                throw new DataStoreException(msg);
            }
            temporaryInUse.add(tempId);
            MessageDigest digest = getDigest();
            DigestInputStream dIn = new DigestInputStream(stream, digest);
            CountingInputStream in = new CountingInputStream(dIn);
            StreamWrapper wrapper;
            if (STORE_SIZE_MINUS_ONE.equals(storeStream)) {
                wrapper = new StreamWrapper(in, -1);
            } else if (STORE_SIZE_MAX.equals(storeStream)) {
                wrapper = new StreamWrapper(in, Integer.MAX_VALUE);
            } else if (STORE_TEMP_FILE.equals(storeStream)) {
                File temp = moveToTempFile(in);
                fileInput = new BufferedInputStream(new TempFileInputStream(temp));
                long length = temp.length();
                wrapper = new StreamWrapper(fileInput, length);
            } else {
                throw new DataStoreException("Unsupported stream store algorithm: " + storeStream);
            }
            // UPDATE DATASTORE SET DATA=? WHERE ID=?
            conHelper.exec(updateDataSQL, new Object[]{wrapper, tempId});
            now = System.currentTimeMillis();
            long length = in.getByteCount();
            DataIdentifier identifier = new DataIdentifier(digest.digest());
            usesIdentifier(identifier);
            id = identifier.toString();
            // UPDATE DATASTORE SET ID=?, LENGTH=?, LAST_MODIFIED=?
            // WHERE ID=?
View Full Code Here

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

     * @throws IOException if an I/O error occurs.
     */
    public BundleReader(BundleBinding binding, InputStream stream)
            throws IOException {
        this.binding = binding;
        this.cin = new CountingInputStream(stream);
        this.in = new DataInputStream(cin);
        this.version = in.readUnsignedByte();
    }
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.