Package java.util.zip

Examples of java.util.zip.InflaterOutputStream


    /**
     * @tests java.util.zip.InflaterOutputStream#write(byte[],int,int)
     */
    public void test_write_$BII_Illegal() throws IOException {
        // write error compression (ZIP) format
        InflaterOutputStream ios = new InflaterOutputStream(os);
        byte[] bytes = { 0, 1, 2, 3 };
        try {
            ios.write(bytes, 0, 4);
            fail("Should throw ZipException");
        } catch (ZipException e) {
            // expected
        }
        try {
            ios.flush();
            fail("Should throw ZipException");
        } catch (ZipException e) {
            // expected
        }

        // write after close
        ios = new InflaterOutputStream(os);
        ios.close();
        try {
            ios.write(bytes, 0, 4);
            fail("Should throw IOException");
        } catch (IOException e) {
            // expected
        }
        try {
            ios.write(bytes, -1, 4);
            fail("Should throw IOException");
        } catch (IOException e) {
            // expected
        }
        try {
            ios.write(bytes, -1, -4);
            fail("Should throw IOException");
        } catch (IOException e) {
            // expected
        }
        try {
            ios.write(bytes, 0, 400);
            fail("Should throw IOException");
        } catch (IOException e) {
            // expected
        }
        try {
            ios.write(null, -1, 4);
            fail("Should throw IOException");
        } catch (IOException e) {
            // expected
        }

        ios = new InflaterOutputStream(os);
        try {
            ios.write(null, 0, 4);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
        try {
            ios.write(null, -1, 4);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
        try {
            ios.write(null, 0, -4);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
        try {
            ios.write(null, 0, 1000);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
        try {
            ios.write(bytes, -1, 4);
            fail("Should throw IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ios.write(bytes, 0, -4);
            fail("Should throw IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ios.write(bytes, 0, 100);
            fail("Should throw IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ios.write(bytes, -100, 100);
            fail("Should throw IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            // expected
        }

        ios = new InflaterOutputStream(os);
        ios.finish();
       
        try {
            ios.write(bytes, -1,-100);
            fail("Should throw IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            // expected
        }
        try {
            ios.write(null, -1,-100);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
       
        ios = new InflaterOutputStream(os);
        ios.flush();
        try {
            ios.write(bytes, 0, 4);
            fail("Should throw ZipException");
        } catch (ZipException e) {
            // expected
        }
    }
View Full Code Here


   */
  @Override
  public void decompress(IIOByteBuffer buf, Box2i range) {
    try {
      ByteArrayOutputStream bytes = new ByteArrayOutputStream();
      InflaterOutputStream inf = new InflaterOutputStream(bytes);
      inf.write(buf.getData(), buf.getOffset(), buf.getLength());
      inf.close();

      byte[] data = bytes.toByteArray();
      for (int i = 1, n = bytes.size(); i < n; i++) {
        data[i] = (byte) (((int) data[i - 1]) + ((int) data[i]) - 128);
      }
View Full Code Here

    }

    private String processPayload(byte[] payload)
        throws IOException, UnsupportedEncodingException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        InflaterOutputStream ios = new InflaterOutputStream(baos);
        ios.write(payload);
        ios.finish();
        return baos.toString();
    }
View Full Code Here

        return decodeCubeModel(modelStr);
    }

    public static Cube decodeCubeModel(String encoded) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        OutputStream os = new InflaterOutputStream(baos, new Inflater(false));
        os.write(Base64.decodeBase64(encoded.getBytes("US-ASCII")));
        os.close();
        return parseYamlModel(new String(baos.toByteArray(), "utf-8"));
    }
View Full Code Here

        List<HuffNode> pathDictionary = new ArrayList<HuffNode>();
        List<HuffNode> nodeDictionary = new ArrayList<HuffNode>();

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        Inflater i = new Inflater();
        InflaterOutputStream ios = new InflaterOutputStream(baos, i);
        ios.write(payload);
        ios.finish();
        long read = i.getBytesRead();

        String name = "";
        int weight = 1;
        for (byte b : baos.toByteArray()) {
View Full Code Here

    // to avoid linking all that jazz into the client code

    public static byte[] gunzipBytes(byte[] compressedBytes) throws IOException
    {
        ByteArrayOutputStream bos = new ByteArrayOutputStream((int)(compressedBytes.length * 1.5));
        InflaterOutputStream dos = new InflaterOutputStream(bos);
        dos.write(compressedBytes);
        dos.close();
        return bos.toByteArray();
    }
View Full Code Here

    }

    public static byte[] gunzipBytes(byte[] compressedBytes) throws IOException
    {
        ByteArrayOutputStream bos = new ByteArrayOutputStream((int)(compressedBytes.length * 1.5));
        InflaterOutputStream dos = new InflaterOutputStream(bos);
        dos.write(compressedBytes);
        dos.close();
        return bos.toByteArray();
    }
View Full Code Here

     * @return byte[] 解压缩后的数据
     * @throws IOException
     */
    public static byte[] decompress(byte[] data) throws IOException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        InflaterOutputStream zos = new InflaterOutputStream(bos);
        StreamUtil.writeAndClose(zos, data);
        return bos.toByteArray();
    }
View Full Code Here

     * @return byte[] 解压缩后的数据
     * @throws IOException
     */
    public static byte[] decompress(byte[] data) throws IOException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        InflaterOutputStream zos = new InflaterOutputStream(bos);
        Finally.writeAndClose(zos, data);
        return bos.toByteArray();
    }
View Full Code Here

    /**
     * Inflates compressed data to an <code>OutputStream</code>.
     */
    public static void inflateToOutputStream(byte[] compressedBytes, OutputStream outstream) throws IOException {
        InflaterOutputStream wrapper = new InflaterOutputStream(outstream);
        wrapper.write(compressedBytes);
    }
View Full Code Here

TOP

Related Classes of java.util.zip.InflaterOutputStream

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.