Examples of RandomAccessFileOutputStream


Examples of org.apache.pdfbox.io.RandomAccessFileOutputStream

        if( length == 0 )
        {
            //if the length is zero then don't bother trying to decode
            //some filters don't work when attempting to decode
            //with a zero length stream.  See zlib_error_01.pdf
            unFilteredStream = new RandomAccessFileOutputStream( file );
            done = true;
        }
        else
        {
            //ok this is a simple hack, sometimes we read a couple extra
            //bytes that shouldn't be there, so we encounter an error we will just
            //try again with one less byte.
            for( int tryCount=0; !done && tryCount<5; tryCount++ )
            {
                try
                {
                    input = new BufferedInputStream(
                        new RandomAccessFileInputStream( file, position, length ), BUFFER_SIZE );
                    unFilteredStream = new RandomAccessFileOutputStream( file );
                    filter.decode( input, unFilteredStream, this, filterIndex );
                    done = true;
                }
                catch( IOException io )
                {
                    length--;
                    exception = io;
                }
            }
            if( !done )
            {
                //if no good stream was found then lets try again but with the
                //length of data that was actually read and not length
                //defined in the dictionary
                length = writtenLength;
                for( int tryCount=0; !done && tryCount<5; tryCount++ )
                {
                    try
                    {
                        input = new BufferedInputStream(
                            new RandomAccessFileInputStream( file, position, length ), BUFFER_SIZE );
                        unFilteredStream = new RandomAccessFileOutputStream( file );
                        filter.decode( input, unFilteredStream, this, filterIndex );
                        done = true;
                    }
                    catch( IOException io )
                    {
View Full Code Here

Examples of org.apache.pdfbox.io.RandomAccessFileOutputStream

        InputStream input;

        input = new BufferedInputStream(
            new RandomAccessFileInputStream( file, filteredStream.getPosition(),
                                                   filteredStream.getLength() ), BUFFER_SIZE );
        filteredStream = new RandomAccessFileOutputStream( file );
        filter.encode( input, filteredStream, this, filterIndex );
    }
View Full Code Here

Examples of org.apache.pdfbox.io.RandomAccessFileOutputStream

     *
     * @throws IOException If there is an error creating the stream.
     */
    public OutputStream createFilteredStream() throws IOException
    {
        filteredStream = new RandomAccessFileOutputStream( file );
        unFilteredStream = null;
        return new BufferedOutputStream( filteredStream, BUFFER_SIZE );
    }
View Full Code Here

Examples of org.apache.pdfbox.io.RandomAccessFileOutputStream

     *
     * @throws IOException If there is an error creating the stream.
     */
    public OutputStream createFilteredStream( COSBase expectedLength ) throws IOException
    {
        filteredStream = new RandomAccessFileOutputStream( file );
        filteredStream.setExpectedLength( expectedLength );
        unFilteredStream = null;
        return new BufferedOutputStream( filteredStream, BUFFER_SIZE );
    }
View Full Code Here

Examples of org.apache.pdfbox.io.RandomAccessFileOutputStream

     *
     * @throws IOException If there is an error creating the stream.
     */
    public OutputStream createUnfilteredStream() throws IOException
    {
        unFilteredStream = new RandomAccessFileOutputStream( file );
        filteredStream = null;
        return new BufferedOutputStream( unFilteredStream, BUFFER_SIZE );
    }
View Full Code Here

Examples of org.gradle.internal.io.RandomAccessFileOutputStream

        public void write() throws Exception {
            long pos = getPos().getPos();
            file.seek(pos);

            Crc32OutputStream checkSumOutputStream = new Crc32OutputStream(new BufferedOutputStream(
                    new RandomAccessFileOutputStream(file)));
            DataOutputStream outputStream = new DataOutputStream(checkSumOutputStream);

            BlockPayload payload = getPayload();

            // Write header
View Full Code Here

Examples of org.gradle.internal.io.RandomAccessFileOutputStream

    }

    public void writeLockInfo(RandomAccessFile lockFileAccess, LockInfo lockInfo) throws IOException {
        lockFileAccess.seek(infoRegionPos);

        DataOutputStream outstr = new DataOutputStream(new BufferedOutputStream(new RandomAccessFileOutputStream(lockFileAccess)));
        outstr.writeByte(lockInfoSerializer.getVersion());
        lockInfoSerializer.write(outstr, lockInfo);
        outstr.flush();

        lockFileAccess.setLength(lockFileAccess.getFilePointer());
View Full Code Here

Examples of org.jf.util.RandomAccessFileOutputStream

        this.raf = new RandomAccessFile(file, "rw");
        this.raf.setLength(0);
    }

    @Nonnull @Override public OutputStream outputAt(int offset) {
        return new RandomAccessFileOutputStream(raf, offset);
    }
View Full Code Here

Examples of org.jwat.common.RandomAccessFileOutputStream

            raf = new RandomAccessFile(out_file, "rw");
            raf.seek(0);
            raf.setLength(0);
            //OutputStream out = new FileOutputStream( "WarcWriteTest.warc" );
            OutputStream out = new RandomAccessFileOutputStream( raf );

            reader = WarcReaderFactory.getReader( in );

            if (bBuffer) {
                writer = WarcWriterFactory.getWriter(out, 8192, bCompress);
            } else {
                writer = WarcWriterFactory.getWriter(out, bCompress);
            }

            //System.out.println(writer);

            records = 0;
            errors = 0;
            warnings = 0;

            while ( (record = reader.getNextRecord()) != null ) {
                if (bDebugOutput) {
                    TestBaseUtils.printRecord(record);
                    TestBaseUtils.printRecordErrors(record);
                }

                ++records;

                if (record.diagnostics.hasErrors()) {
                    errors += record.diagnostics.getErrors().size();
                }
                if (record.diagnostics.hasWarnings()) {
                    warnings += record.diagnostics.getWarnings().size();
                }

                writer.writeHeader(record);

                if ( record.hasPayload() ) {
                    Payload payload = record.getPayload();
                    //writer.transfer( payload.getInputStream(), payload.getTotalLength() );
                    writer.streamPayload( payload.getInputStreamComplete() );
                }

                writer.closeRecord();
            }

            if (bDebugOutput) {
                System.out.println("--------------");
                System.out.println("       Records: " + records);
                System.out.println("        Errors: " + errors);
            }

            reader.close();
            in.close();
            writer.close();
            out.close();

            Assert.assertEquals(expected_records, records);
            Assert.assertTrue(reader.isCompliant());
            Assert.assertEquals(0, errors);
            Assert.assertEquals(0, warnings);
            Assert.assertEquals(11231015, reader.getConsumed());

            /*
             * Validate written warc.
             */

            raf.seek(0);
            in = new RandomAccessFileInputStream( raf );

            reader = WarcReaderFactory.getReader( in );

            //System.out.println(reader);

            records = 0;
            errors = 0;
            warnings = 0;

            while ( (record = reader.getNextRecord()) != null ) {
                if (bDebugOutput) {
                    TestBaseUtils.printRecord(record);
                    TestBaseUtils.printRecordErrors(record);
                }

                ++records;

                if (record.diagnostics.hasErrors()) {
                    errors += record.diagnostics.getErrors().size();
                }
                if (record.diagnostics.hasWarnings()) {
                    warnings += record.diagnostics.getWarnings().size();
                }
            }

            if (bDebugOutput) {
                System.out.println("--------------");
                System.out.println("       Records: " + records);
                System.out.println("        Errors: " + errors);
            }

            reader.close();
            in.close();
            writer.close();
            out.close();

            Assert.assertEquals(expected_records, records);
            Assert.assertTrue(reader.isCompliant());
            Assert.assertEquals(0, errors);
            Assert.assertEquals(0, warnings);
View Full Code Here

Examples of org.jwat.common.RandomAccessFileOutputStream

            raf = new RandomAccessFile(out_file, "rw");
            raf.seek(0);
            raf.setLength(0);
            //OutputStream out = new FileOutputStream( "WarcWriteTest.warc" );
            OutputStream out = new RandomAccessFileOutputStream( raf );

            reader = WarcReaderFactory.getReader( in );

            if (bBuffer) {
                writer = WarcWriterFactory.getWriter(out, 8192, bCompress);
            } else {
                writer = WarcWriterFactory.getWriter(out, bCompress);
            }

            //System.out.println(writer);

            records = 0;
            errors = 0;
            warnings = 0;

            while ( (record = reader.getNextRecord()) != null ) {
                if (bDebugOutput) {
                    TestBaseUtils.printRecord(record);
                    TestBaseUtils.printRecordErrors(record);
                }

                ++records;

                if (record.diagnostics.hasErrors()) {
                    errors += record.diagnostics.getErrors().size();
                }
                if (record.diagnostics.hasWarnings()) {
                    warnings += record.diagnostics.getWarnings().size();
                }

                writer.writeRawHeader(record.header.headerBytes, record.header.contentLength);

                if ( record.hasPayload() ) {
                    Payload payload = record.getPayload();
                    //writer.transfer( payload.getInputStream(), payload.getTotalLength() );
                    writer.streamPayload( payload.getInputStreamComplete() );
                }

                writer.closeRecord();
            }

            if (bDebugOutput) {
                System.out.println("--------------");
                System.out.println("       Records: " + records);
                System.out.println("        Errors: " + errors);
            }

            reader.close();
            in.close();
            writer.close();
            out.close();

            Assert.assertEquals(expected_records, records);
            Assert.assertTrue(reader.isCompliant());
            Assert.assertEquals(0, errors);
            Assert.assertEquals(0, warnings);
            Assert.assertEquals(11231015, reader.getConsumed());

            /*
             * Validate written warc.
             */

            raf.seek(0);
            in = new RandomAccessFileInputStream( raf );

            reader = WarcReaderFactory.getReader( in );

            //System.out.println(reader);

            records = 0;
            errors = 0;
            warnings = 0;

            while ( (record = reader.getNextRecord()) != null ) {
                if (bDebugOutput) {
                    TestBaseUtils.printRecord(record);
                    TestBaseUtils.printRecordErrors(record);
                }

                ++records;

                if (record.diagnostics.hasErrors()) {
                    errors += record.diagnostics.getErrors().size();
                }
                if (record.diagnostics.hasWarnings()) {
                    warnings += record.diagnostics.getWarnings().size();
                }
            }

            if (bDebugOutput) {
                System.out.println("--------------");
                System.out.println("       Records: " + records);
                System.out.println("        Errors: " + errors);
            }

            reader.close();
            in.close();
            writer.close();
            out.close();

            Assert.assertEquals(expected_records, records);
            Assert.assertTrue(reader.isCompliant());
            Assert.assertEquals(0, errors);
            Assert.assertEquals(0, warnings);
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.