Package java.util.zip

Examples of java.util.zip.DeflaterOutputStream


      throw ERT.badarg(bin);
    }
   
    Deflater defl = new Deflater();
    BARR bos = new BARR();
    DeflaterOutputStream dos = new DeflaterOutputStream(bos, defl);
   
    try {
      b.writeTo(dos);
      dos.close();
    } catch (IOException e) {
      throw new InternalError("should not happen");
    }
   
    return bos.asBinary();   
View Full Code Here


      //这种模式下是否覆盖原文件参数无效,每次都会覆盖
      if (needCompress)
      {
        Deflater def = new Deflater(Deflater.BEST_SPEED, false);
     
        bwriter = new BufferedWriter(new OutputStreamWriter(new DeflaterOutputStream(
          new FileOutputStream(FileName), def), "GBK"));
      }
      else   
        bwriter = new BufferedWriter(new OutputStreamWriter(
          new FileOutputStream(FileName,!needOverwrite), "GBK"));
View Full Code Here

    private ByteArrayOutputStream deflate(byte[] inflatedImageData, int strategy, int compression) throws IOException {
        ByteArrayOutputStream deflatedOut = new ByteArrayOutputStream();
        Deflater deflater = new Deflater(compression);
        deflater.setStrategy(strategy);

        DeflaterOutputStream stream = new DeflaterOutputStream(deflatedOut, deflater);
        stream.write(inflatedImageData);
        stream.close();

        return deflatedOut;
    }
View Full Code Here

            Deflater compresser = new Deflater();
           
            byte[] input = baos.toByteArray();
           
            ByteArrayOutputStream compressed = new ByteArrayOutputStream();
            DataOutputStream dout = new DataOutputStream(new DeflaterOutputStream(compressed, compresser));
           
            dout.write(input);
           
            dout.close();
            compressed.close();
View Full Code Here

        return bytes_total;
    }

    public void doFilter(InputStream in,
                         OutputStream out) throws IOException {
        DeflaterOutputStream dout = new DeflaterOutputStream(out);
        copyStream(in, dout, 2048);
        // dout.flush();
        dout.close();
    }
View Full Code Here

    OutputStream out
    ) throws IOException
  {
    // Compress the data
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    OutputStream deflater = new DeflaterOutputStream(baos);
    deflater.write(data);
    deflater.flush();
    deflater.close();

    // Write out the IDAT chunk
    _writeChunk(_IDAT, baos.toByteArray(), out);
  }
View Full Code Here

     */
    public byte[] encode(byte[] data) {
        ByteArrayOutputStream outArrayStream = new ByteArrayOutputStream();
        _predictor = PREDICTION_NONE;
        try {
            DeflaterOutputStream compressedStream =
                new DeflaterOutputStream(outArrayStream);
            compressedStream.write(data, 0, data.length);
            compressedStream.flush();
            compressedStream.close();
        } catch (IOException e) {
            org.apache.fop.messaging.MessageHandler.error("Fatal error: "
                    + e.getMessage());
            e.printStackTrace();
        }
View Full Code Here

        }
    }

    private void writeIDAT() throws IOException {
        IDATOutputStream ios = new IDATOutputStream(dataOutput, 8192);
        DeflaterOutputStream dos =
            new DeflaterOutputStream(ios, new Deflater(9));

        // Future work - don't convert entire image to a Raster It
        // might seem that you could just call image.getData() but
        // 'BufferedImage.subImage' doesn't appear to set the Width
        // and height properly of the Child Raster, so the Raster
        // you get back here appears larger than it should.
        // This solves that problem by bounding the raster to the
        // image's bounds...
        Raster ras = image.getData(new Rectangle(image.getMinX(),
                                                 image.getMinY(),
                                                 image.getWidth(),
                                                 image.getHeight()));
        // System.out.println("Image: [" +
        //                    image.getMinY()  + ", " +
        //                    image.getMinX()  + ", " +
        //                    image.getWidth()  + ", " +
        //                    image.getHeight() + "]");
        // System.out.println("Ras: [" +
        //                    ras.getMinX()  + ", " +
        //                    ras.getMinY()  + ", " +
        //                    ras.getWidth()  + ", " +
        //                    ras.getHeight() + "]");

        if (skipAlpha) {
            int numBands = ras.getNumBands() - 1;
            int[] bandList = new int[numBands];
            for (int i = 0; i < numBands; i++) {
                bandList[i] = i;
            }
            ras = ras.createChild(0, 0,
                                  ras.getWidth(), ras.getHeight(),
                                  0, 0,
                                  bandList);
        }

        if (interlace) {
            // Interlacing pass 1
            encodePass(dos, ras, 0, 0, 8, 8);
            // Interlacing pass 2
            encodePass(dos, ras, 4, 0, 8, 8);
            // Interlacing pass 3
            encodePass(dos, ras, 0, 4, 4, 8);
            // Interlacing pass 4
            encodePass(dos, ras, 2, 0, 4, 4);
            // Interlacing pass 5
            encodePass(dos, ras, 0, 2, 2, 4);
            // Interlacing pass 6
            encodePass(dos, ras, 1, 0, 2, 2);
            // Interlacing pass 7
            encodePass(dos, ras, 0, 1, 1, 2);
        } else {
            encodePass(dos, ras, 0, 0, 1, 1);
        }

        dos.finish();
        dos.close();
        ios.flush();
        ios.close();
    }
View Full Code Here

                cs.write(keyword, 0, Math.min(keyword.length, 79));
                cs.write(0);
                cs.write(0);

                DeflaterOutputStream dos = new DeflaterOutputStream(cs);
                dos.write(value);
                dos.finish();
                dos.close();

                cs.writeToStream(dataOutput);
                cs.close();
            }
        }
View Full Code Here

        }
        for (int i = 256; i < test.length; i++) {
            test[i] = (byte) (256 - i);
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DeflaterOutputStream dos = new DeflaterOutputStream(baos);
        dos.write(test);
        dos.close();
        InputStream is = new ByteArrayInputStream(baos.toByteArray());
        InflaterInputStream iis = new InflaterInputStream(is);
        byte[] outBuf = new byte[530];
        int result = 0;
        while (true) {
View Full Code Here

TOP

Related Classes of java.util.zip.DeflaterOutputStream

Copyright © 2018 www.massapicom. 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.