Examples of RandomAccessFileOutputStream


Examples of org.apache.pdfbox.io.RandomAccessFileOutputStream

        {
            //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
            IOUtils.closeQuietly(unFilteredStream);
            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++ )
            {
                InputStream input = null;
                try
                {
                    input = new BufferedInputStream(
                        new RandomAccessFileInputStream( file, position, length ), BUFFER_SIZE );
                  IOUtils.closeQuietly(unFilteredStream);
                    unFilteredStream = new RandomAccessFileOutputStream( file );
                    filter.decode( input, unFilteredStream, this, filterIndex );
                    done = true;
                }
                catch( IOException io )
                {
                    length--;
                    exception = io;
                }
                finally
                {
                  IOUtils.closeQuietly(input);
                }
            }
            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++ )
                {
                    InputStream input = null;
                    try
                    {
                        input = new BufferedInputStream(
                            new RandomAccessFileInputStream( file, position, length ), BUFFER_SIZE );
                      IOUtils.closeQuietly(unFilteredStream);
                        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 = new BufferedInputStream(
            new RandomAccessFileInputStream( file, filteredStream.getPosition(),
                                                   filteredStream.getLength() ), BUFFER_SIZE );
        IOUtils.closeQuietly(filteredStream);
        filteredStream = new RandomAccessFileOutputStream( file );
        filter.encode( input, filteredStream, this, filterIndex );
        IOUtils.closeQuietly(input);
    }
View Full Code Here

Examples of org.apache.pdfbox.io.RandomAccessFileOutputStream

    public OutputStream createFilteredStream() throws IOException
    {
      IOUtils.closeQuietly(unFilteredStream);
      unFilteredStream = null;
      IOUtils.closeQuietly(filteredStream);
        filteredStream = new RandomAccessFileOutputStream( file );
        return new BufferedOutputStream( filteredStream, BUFFER_SIZE );
    }
View Full Code Here

Examples of org.apache.pdfbox.io.RandomAccessFileOutputStream

    public OutputStream createFilteredStream( COSBase expectedLength ) throws IOException
    {
        IOUtils.closeQuietly(unFilteredStream);
         unFilteredStream = null;
      IOUtils.closeQuietly(filteredStream);
        filteredStream = new RandomAccessFileOutputStream( file );
        filteredStream.setExpectedLength( expectedLength );
        return new BufferedOutputStream( filteredStream, BUFFER_SIZE );
    }
View Full Code Here

Examples of org.apache.pdfbox.io.RandomAccessFileOutputStream

    public OutputStream createUnfilteredStream() throws IOException
    {
        IOUtils.closeQuietly(filteredStream);
        filteredStream = null;
      IOUtils.closeQuietly(unFilteredStream);
        unFilteredStream = new RandomAccessFileOutputStream( file );
        return new BufferedOutputStream( unFilteredStream, BUFFER_SIZE );
    }
View Full Code Here

Examples of org.apache.pdfbox.io.RandomAccessFileOutputStream

        {
            //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
            IOUtils.closeQuietly(unFilteredStream);
            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; length > 0 && !done && tryCount < 5; tryCount++)
            {
                InputStream input = null;
                try
                {
                    input = new BufferedInputStream(
                        new RandomAccessFileInputStream( file, position, length ), BUFFER_SIZE );
                  IOUtils.closeQuietly(unFilteredStream);
                    unFilteredStream = new RandomAccessFileOutputStream( file );
                    filter.decode( input, unFilteredStream, this, filterIndex );
                    done = true;
                }
                catch( IOException io )
                {
                    length--;
                    exception = io;
                }
                finally
                {
                  IOUtils.closeQuietly(input);
                }
            }
            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++ )
                {
                    InputStream input = null;
                    try
                    {
                        input = new BufferedInputStream(
                            new RandomAccessFileInputStream( file, position, length ), BUFFER_SIZE );
                      IOUtils.closeQuietly(unFilteredStream);
                        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 = new BufferedInputStream(
            new RandomAccessFileInputStream( file, filteredStream.getPosition(),
                                                   filteredStream.getLength() ), BUFFER_SIZE );
        IOUtils.closeQuietly(filteredStream);
        filteredStream = new RandomAccessFileOutputStream( file );
        filter.encode( input, filteredStream, this, filterIndex );
        IOUtils.closeQuietly(input);
    }
View Full Code Here

Examples of org.apache.pdfbox.io.RandomAccessFileOutputStream

    public OutputStream createFilteredStream() throws IOException
    {
      IOUtils.closeQuietly(unFilteredStream);
      unFilteredStream = null;
      IOUtils.closeQuietly(filteredStream);
        filteredStream = new RandomAccessFileOutputStream( file );
        return new BufferedOutputStream( filteredStream, BUFFER_SIZE );
    }
View Full Code Here

Examples of org.apache.pdfbox.io.RandomAccessFileOutputStream

    public OutputStream createFilteredStream( COSBase expectedLength ) throws IOException
    {
        IOUtils.closeQuietly(unFilteredStream);
         unFilteredStream = null;
      IOUtils.closeQuietly(filteredStream);
        filteredStream = new RandomAccessFileOutputStream( file );
        filteredStream.setExpectedLength( expectedLength );
        return new BufferedOutputStream( filteredStream, BUFFER_SIZE );
    }
View Full Code Here

Examples of org.apache.pdfbox.io.RandomAccessFileOutputStream

    public OutputStream createUnfilteredStream() throws IOException
    {
        IOUtils.closeQuietly(filteredStream);
        filteredStream = null;
      IOUtils.closeQuietly(unFilteredStream);
        unFilteredStream = new RandomAccessFileOutputStream( file );
        return new BufferedOutputStream( unFilteredStream, BUFFER_SIZE );
    }
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.