Examples of ZOutputStream


Examples of bm.core.zlib.ZOutputStream

        if( currentRecord != null && currentRecord.isDirty() )
        {
//            log.debug( "flushing record: " + currentRecord );
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            SerializerOutputStream out;
            ZOutputStream zos = null;
            if( useCompression() )
            {
                log.debug( "Using compression" );
                zos = new ZOutputStream(
                        baos,
                        DeviceInfo.getDeviceInfo().getOptimalCompression()
                );
                out = new SerializerOutputStream( zos );
            }
            else
            {
                out = new SerializerOutputStream( baos );
            }
            try
            {
                open();
                currentRecord.serialize( out );
                out.flush();
                if( useCompression() )
                {
                    //noinspection ConstantConditions
                    zos.flush();
                    zos.close();
                }
                final byte[] data = baos.toByteArray();
                if( currentRecord.getRecordId() > 0 && currentRecord.getRecordId() < rs.getNextRecordID() )
                {
                    //log.debug( "flush: exsiting record " + currentRecord );
View Full Code Here

Examples of bm.core.zlib.ZOutputStream

            throws IOException,
                   RSException,
                   SerializationException
    {
        System.out.println( "Writing index" );
        final ZOutputStream zos = new ZOutputStream(
                os,
                ZStream.Z_BEST_COMPRESSION
        );
        final SerializerOutputStream out = new SerializerOutputStream( zos );

        final int numRecords;
        try
        {
            index.getRecordStore().open();
        }
        catch( RecordStoreFullException e )
        {
            throw new RSException( 0, e );
        }
        final Store rs = index.getRecordStore();
        out.writeInt( index.getOrder() );
        out.writeByte( (byte) index.getType() );
        out.writeBoolean( index.isCaseSensitive() );
        numRecords = rs.getNumRecords();
        System.out.println( "Writing " + numRecords + " records" );
        out.writeInt( numRecords );
        for( int i = 1; i <= numRecords; i++ )
        {
            try
            {
                out.writeBlob( rs.getRecord( i ) );
            }
            catch( InvalidRecordIDException e )
            {
            }
        }
        out.flush();
        zos.flush();
        zos.close();
        System.out.println( "Done" );
    }
View Full Code Here

Examples of bm.core.zlib.ZOutputStream

            throws IOException,
                   RSException,
                   SerializationException
    {
        System.out.println( "Writing index" );
        final ZOutputStream zos = new ZOutputStream(
                os,
                ZStream.Z_BEST_COMPRESSION
        );
        final SerializerOutputStream out = new SerializerOutputStream( zos );

        final int numRecords;
        try
        {
            index.getRecordStore().open();
        }
        catch( RecordStoreFullException e )
        {
            throw new RSException( 0, e );
        }
        final Store rs = index.getRecordStore();
        out.writeInt( index.getOrder() );
        out.writeByte( (byte) index.getType() );
        out.writeBoolean( index.isCaseSensitive() );
        numRecords = rs.getNumRecords();
        System.out.println( "Writing " + numRecords + " records" );
        out.writeInt( numRecords );
        for( int i = 1; i <= numRecords; i++ )
        {
            try
            {
                out.writeBlob( rs.getRecord( i ) );
            }
            catch( InvalidRecordIDException e )
            {
            }
        }
        out.flush();
        zos.flush();
        zos.close();
        System.out.println( "Done" );
    }
View Full Code Here

Examples of com.jcraft.jzlib.ZOutputStream

    public void startCompression() {
        compressed = true;

        try {
            if (tlsStreamHandler == null) {
                ZOutputStream out = new ZOutputStream(
                        ServerTrafficCounter.wrapOutputStream(socket.getOutputStream()),
                        JZlib.Z_BEST_COMPRESSION);
                out.setFlushMode(JZlib.Z_PARTIAL_FLUSH);
                writer = new BufferedWriter(new OutputStreamWriter(out, CHARSET));
                xmlSerializer = new XMLSocketWriter(writer, this);
            }
            else {
                ZOutputStream out = new ZOutputStream(tlsStreamHandler.getOutputStream(), JZlib.Z_BEST_COMPRESSION);
                out.setFlushMode(JZlib.Z_PARTIAL_FLUSH);
                writer = new BufferedWriter(new OutputStreamWriter(out, CHARSET));
                xmlSerializer = new XMLSocketWriter(writer, this);
            }
        } catch (IOException e) {
            // TODO Would be nice to still be able to throw the exception and not catch it here
View Full Code Here

Examples of nu.fw.jeti.plugins.compression.jcraft.jzlib.ZOutputStream

    }
  }
 
  public static OutputStream getCompressedOutputStream(OutputStream out)
  {
    ZOutputStream zOut = new ZOutputStream(out,JZlib.Z_BEST_COMPRESSION);
    zOut.setFlushMode(JZlib.Z_PARTIAL_FLUSH);
    return zOut;
  }
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.