Examples of Inflater


Examples of java.util.zip.Inflater

  public void test_reset() {
    // test method of java.util.zip.inflater.reset()
    byte byteArray[] = { 1, 3, 4, 7, 8, 'e', 'r', 't', 'y', '5' };
    byte outPutInf[] = new byte[100];
    int y = 0;
    Inflater inflate = new Inflater();
    try {
      while (!(inflate.finished())) {
        if (inflate.needsInput()) {
          inflate.setInput(outPutBuff1);
        }
        y += inflate.inflate(outPutInf, y, outPutInf.length - y);
      }
    } catch (DataFormatException e) {
      fail("Invalid input to be decompressed");
    }
    for (int i = 0; i < byteArray.length; i++) {
      assertTrue(
          "Final decompressed data does not equal the original data",
          byteArray[i] == outPutInf[i]);
    }
    assertEquals("final decompressed data contained more bytes than original - reset",
        0, outPutInf[byteArray.length]);

    // testing that resetting the inflater will also return the correct
    // decompressed data

    inflate.reset();
    try {
      while (!(inflate.finished())) {
        if (inflate.needsInput()) {
          inflate.setInput(outPutBuff1);
        }
        inflate.inflate(outPutInf);
      }
    } catch (DataFormatException e) {
      fail("Invalid input to be decompressed");
    }
    for (int i = 0; i < byteArray.length; i++) {
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.