Java 类java.util.zip.Inflater 实例源码

项目:trashjam2017    文件:PNGDecoder.java   
private void readChunkUnzip(Inflater inflater, byte[] buffer, int offset, int length) throws IOException {
    try {
        do {
            int read = inflater.inflate(buffer, offset, length);
            if(read <= 0) {
                if(inflater.finished()) {
                    throw new EOFException();
                }
                if(inflater.needsInput()) {
                    refillInflater(inflater);
                } else {
                    throw new IOException("Can't inflate " + length + " bytes");
                }
            } else {
                offset += read;
                length -= read;
            }
        } while(length > 0);
    } catch (DataFormatException ex) {
        throw (IOException)(new IOException("inflate error").initCause(ex));
    }
}
项目:sstable-adaptor    文件:DeflateCompressor.java   
public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, int maxOutputLength) throws IOException
{
    Inflater inf = inflater.get();
    inf.reset();
    inf.setInput(input, inputOffset, inputLength);
    if (inf.needsInput())
        return 0;

    // We assume output is big enough
    try
    {
        return inf.inflate(output, outputOffset, maxOutputLength);
    }
    catch (DataFormatException e)
    {
        throw new IOException(e);
    }
}
项目:HeadlineNews    文件:LogUtils.java   
public static byte[] uncompress(final byte[] input) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    Inflater decompressor = new Inflater();
    try {
        decompressor.setInput(input);
        final byte[] buf = new byte[2048];
        while (!decompressor.finished()) {
            int count = 0;
            try {
                count = decompressor.inflate(buf);
            } catch (DataFormatException e) {
                e.printStackTrace();
            }
            bos.write(buf, 0, count);
        }
    } finally {
        decompressor.end();
    }
    return bos.toByteArray();
}
项目:k-framework    文件:SecureUtil.java   
/**
 * 解压缩.
 * 
 * @param inputByte
 *            byte[]数组类型的数据
 * @return 解压缩后的数据
 * @throws IOException
 */
public static byte[] inflater(final byte[] inputByte) throws IOException {
    int compressedDataLength = 0;
    Inflater compresser = new Inflater(false);
    compresser.setInput(inputByte, 0, inputByte.length);
    ByteArrayOutputStream o = new ByteArrayOutputStream(inputByte.length);
    byte[] result = new byte[1024];
    try {
        while (!compresser.finished()) {
            compressedDataLength = compresser.inflate(result);
            if (compressedDataLength == 0) {
                break;
            }
            o.write(result, 0, compressedDataLength);
        }
    } catch (Exception ex) {
        System.err.println("Data format error!\n");
        ex.printStackTrace();
    } finally {
        o.close();
    }
    compresser.end();
    return o.toByteArray();
}
项目:nutz-pay    文件:SDKUtil.java   
/**
 * 解压缩.
 *
 * @param inputByte byte[]数组类型的数据
 * @return 解压缩后的数据
 * @throws IOException
 */
public static byte[] inflater(final byte[] inputByte) throws IOException {
    int compressedDataLength = 0;
    Inflater compresser = new Inflater(false);
    compresser.setInput(inputByte, 0, inputByte.length);
    ByteArrayOutputStream o = new ByteArrayOutputStream(inputByte.length);
    byte[] result = new byte[1024];
    try {
        while (!compresser.finished()) {
            compressedDataLength = compresser.inflate(result);
            if (compressedDataLength == 0) {
                break;
            }
            o.write(result, 0, compressedDataLength);
        }
    } catch (Exception ex) {
        System.err.println("Data format error!\n");
        ex.printStackTrace();
    } finally {
        o.close();
    }
    compresser.end();
    return o.toByteArray();
}
项目:springboot-shiro-cas-mybatis    文件:FrontChannelLogoutActionTests.java   
@Test
public void verifyLogoutOneLogoutRequestNotAttempted() throws Exception {
    final SingleLogoutService service = new WebApplicationServiceFactory().createService(TEST_URL, SingleLogoutService.class);
    final LogoutRequest logoutRequest = new DefaultLogoutRequest(TICKET_ID,
            service,
            new URL(TEST_URL));
    final Event event = getLogoutEvent(Arrays.asList(logoutRequest));

    assertEquals(FrontChannelLogoutAction.REDIRECT_APP_EVENT, event.getId());
    final List<LogoutRequest> list = WebUtils.getLogoutRequests(this.requestContext);
    assertEquals(1, list.size());
    final String url = (String) event.getAttributes().get(FrontChannelLogoutAction.DEFAULT_FLOW_ATTRIBUTE_LOGOUT_URL);
    assertTrue(url.startsWith(TEST_URL + '?' + FrontChannelLogoutAction.DEFAULT_LOGOUT_PARAMETER + '='));
    final byte[] samlMessage = CompressionUtils.decodeBase64ToByteArray(
            URLDecoder.decode(StringUtils.substringAfter(url, '?' + FrontChannelLogoutAction.DEFAULT_LOGOUT_PARAMETER + '='), "UTF-8"));
    final Inflater decompresser = new Inflater();
    decompresser.setInput(samlMessage);
    final byte[] result = new byte[1000];
    decompresser.inflate(result);
    decompresser.end();
    final String message = new String(result);
    assertTrue(message.startsWith("<samlp:LogoutRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\""));
    assertTrue(message.contains("<samlp:SessionIndex>" + TICKET_ID + "</samlp:SessionIndex>"));
}
项目:springboot-shiro-cas-mybatis    文件:FrontChannelLogoutActionTests.java   
@Test
public void verifyLogoutOneLogoutRequestNotAttempted() throws Exception {
    final LogoutRequest logoutRequest = new DefaultLogoutRequest(TICKET_ID,
            new SimpleWebApplicationServiceImpl(TEST_URL),
            new URL(TEST_URL));
    final Event event = getLogoutEvent(Arrays.asList(logoutRequest));

    assertEquals(FrontChannelLogoutAction.REDIRECT_APP_EVENT, event.getId());
    final List<LogoutRequest> list = WebUtils.getLogoutRequests(this.requestContext);
    assertEquals(1, list.size());
    final String url = (String) event.getAttributes().get(FrontChannelLogoutAction.DEFAULT_FLOW_ATTRIBUTE_LOGOUT_URL);
    assertTrue(url.startsWith(TEST_URL + "?" + FrontChannelLogoutAction.DEFAULT_LOGOUT_PARAMETER + "="));
    final byte[] samlMessage = CompressionUtils.decodeBase64ToByteArray(
            URLDecoder.decode(StringUtils.substringAfter(url, "?" + FrontChannelLogoutAction.DEFAULT_LOGOUT_PARAMETER + "="), "UTF-8"));
    final Inflater decompresser = new Inflater();
    decompresser.setInput(samlMessage);
    final byte[] result = new byte[1000];
    decompresser.inflate(result);
    decompresser.end();
    final String message = new String(result);
    assertTrue(message.startsWith("<samlp:LogoutRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\""));
    assertTrue(message.contains("<samlp:SessionIndex>" + TICKET_ID + "</samlp:SessionIndex>"));
}
项目:boohee_v5.6    文件:bs.java   
public static byte[] b(byte[] bArr) throws UnsupportedEncodingException, DataFormatException {
    int i = 0;
    if (bArr == null || bArr.length == 0) {
        return null;
    }
    Inflater inflater = new Inflater();
    inflater.setInput(bArr, 0, bArr.length);
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    byte[] bArr2 = new byte[1024];
    while (!inflater.needsInput()) {
        int inflate = inflater.inflate(bArr2);
        byteArrayOutputStream.write(bArr2, i, inflate);
        i += inflate;
    }
    inflater.end();
    return byteArrayOutputStream.toByteArray();
}
项目:cas-5.1.0    文件:CompressionUtils.java   
/**
 * Inflate the given byte array by {@link #INFLATED_ARRAY_LENGTH}.
 *
 * @param bytes the bytes
 * @return the array as a string with {@code UTF-8} encoding
 */
public static String inflate(final byte[] bytes) {
    final Inflater inflater = new Inflater(true);
    final byte[] xmlMessageBytes = new byte[INFLATED_ARRAY_LENGTH];

    final byte[] extendedBytes = new byte[bytes.length + 1];
    System.arraycopy(bytes, 0, extendedBytes, 0, bytes.length);
    extendedBytes[bytes.length] = 0;

    inflater.setInput(extendedBytes);

    try {
        final int resultLength = inflater.inflate(xmlMessageBytes);
        inflater.end();

        if (!inflater.finished()) {
            throw new RuntimeException("buffer not large enough.");
        }

        inflater.end();
        return new String(xmlMessageBytes, 0, resultLength, StandardCharsets.UTF_8);
    } catch (final DataFormatException e) {
        return null;
    }
}
项目:wakeup-qcloud-sdk    文件:DefaultQCloudClient.java   
@Override
public boolean verifyUserSig(String identifier, String sig)throws QCloudException {
    try {
        Security.addProvider(new BouncyCastleProvider());

        //DeBaseUrl64 urlSig to json
        Base64 decoder = new Base64();

        byte [] compressBytes = Base64Url.base64DecodeUrl(sig.getBytes(Charset.forName("UTF-8")));

        //Decompression
        Inflater decompression =  new Inflater();
        decompression.setInput(compressBytes, 0, compressBytes.length);
        byte [] decompressBytes = new byte [1024];
        int decompressLength = decompression.inflate(decompressBytes);
        decompression.end();

        String jsonString = new String(Arrays.copyOfRange(decompressBytes, 0, decompressLength));

        //Get TLS.Sig from json
        JSONObject jsonObject= JSON.parseObject(jsonString);
        String sigTLS = jsonObject.getString("TLS.sig");

        //debase64 TLS.Sig to get serailString
        byte[] signatureBytes = decoder.decode(sigTLS.getBytes(Charset.forName("UTF-8")));

        String strSdkAppid = jsonObject.getString("TLS.sdk_appid");
        String sigTime = jsonObject.getString("TLS.time");
        String sigExpire = jsonObject.getString("TLS.expire_after");

        if (!imConfig.getSdkAppId().equals(strSdkAppid))
        {
            return false;
        }

        if ( System.currentTimeMillis()/1000 - Long.parseLong(sigTime) > Long.parseLong(sigExpire)) {
            return false;
        }

        //Get Serial String from json
        String SerialString = 
            "TLS.appid_at_3rd:" + 0 + "\n" +
            "TLS.account_type:" + 0 + "\n" +
            "TLS.identifier:" + identifier + "\n" + 
            "TLS.sdk_appid:" + imConfig.getSdkAppId() + "\n" + 
            "TLS.time:" + sigTime + "\n" + 
            "TLS.expire_after:" + sigExpire + "\n";

        Reader reader = new CharArrayReader(imConfig.getPublicKey().toCharArray());
        PEMParser  parser = new PEMParser(reader);
        JcaPEMKeyConverter converter = new JcaPEMKeyConverter();
        Object obj = parser.readObject();
        parser.close();
        PublicKey pubKeyStruct  = converter.getPublicKey((SubjectPublicKeyInfo) obj);

        Signature signature = Signature.getInstance("SHA256withECDSA","BC");
        signature.initVerify(pubKeyStruct);
        signature.update(SerialString.getBytes(Charset.forName("UTF-8")));
        return signature.verify(signatureBytes);
    }catch (Exception e) {
        throw new QCloudException(e);
    }
}
项目:Android-UtilCode    文件:LogUtils.java   
public static byte[] uncompress(byte[] input) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    Inflater decompressor = new Inflater();
    try {
        decompressor.setInput(input);
        final byte[] buf = new byte[2048];
        while (!decompressor.finished()) {
            int count = 0;
            try {
                count = decompressor.inflate(buf);
            } catch (DataFormatException e) {
                e.printStackTrace();
            }
            bos.write(buf, 0, count);
        }
    } finally {
        decompressor.end();
    }
    return bos.toByteArray();
}
项目:unionpay    文件:SDKUtil.java   
/**
 * 解压缩.
 * 
 * @param inputByte
 *            byte[]数组类型的数据
 * @return 解压缩后的数据
 * @throws IOException
 */
public static byte[] inflater(final byte[] inputByte) throws IOException {
    int compressedDataLength = 0;
    Inflater compresser = new Inflater(false);
    compresser.setInput(inputByte, 0, inputByte.length);
    ByteArrayOutputStream o = new ByteArrayOutputStream(inputByte.length);
    byte[] result = new byte[1024];
    try {
        while (!compresser.finished()) {
            compressedDataLength = compresser.inflate(result);
            if (compressedDataLength == 0) {
                break;
            }
            o.write(result, 0, compressedDataLength);
        }
    } catch (Exception ex) {
        System.err.println("Data format error!\n");
        ex.printStackTrace();
    } finally {
        o.close();
    }
    compresser.end();
    return o.toByteArray();
}
项目:Progetto-C    文件:PNGDecoder.java   
private void readChunkUnzip(Inflater inflater, byte[] buffer, int offset, int length) throws IOException {
    try {
        do {
            int read = inflater.inflate(buffer, offset, length);
            if(read <= 0) {
                if(inflater.finished()) {
                    throw new EOFException();
                }
                if(inflater.needsInput()) {
                    refillInflater(inflater);
                } else {
                    throw new IOException("Can't inflate " + length + " bytes");
                }
            } else {
                offset += read;
                length -= read;
            }
        } while(length > 0);
    } catch (DataFormatException ex) {
        throw (IOException)(new IOException("inflate error").initCause(ex));
    }
}
项目:mi-firma-android    文件:Dnie.java   
/** Descomprime un certificado contenido en el DNIe.
 * @param compressedCertificate Certificado comprimido en ZIP a partir del 9 byte.
 * @return Certificado codificado.
 * @throws IOException Cuando se produce un error en la descompresion del certificado. */
private static byte[] deflate(final byte[] compressedCertificate) throws IOException {
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    final Inflater decompressor = new Inflater();
    decompressor.setInput(compressedCertificate, 8, compressedCertificate.length - 8);
    final byte[] buf = new byte[1024];
    try {
        // Descomprimimos los datos
        while (!decompressor.finished()) {
            final int count = decompressor.inflate(buf);
            if (count == 0) {
                throw new DataFormatException();
            }
            buffer.write(buf, 0, count);
        }
        // Obtenemos los datos descomprimidos
        return buffer.toByteArray();
    }
    catch (final DataFormatException ex) {
        throw new IOException("Error al descomprimir el certificado: " + ex, ex); //$NON-NLS-1$
    }
}
项目:spring-web-jsflow    文件:CompressionCodec.java   
@Override
public OneWayCodec createDecoder() throws Exception {
    return new OneWayCodec() {
        private final Inflater inflater = new Inflater();

        @Override
        public byte[] code(final byte[] data) throws Exception {
            inflater.reset();
            final InflaterInputStream in = new InflaterInputStream(new ByteArrayInputStream(data), inflater);
            final ByteArrayOutputStream out = new ByteArrayOutputStream(data.length * 2);
            final byte[] b = new byte[512];
            for (;;) {
                final int i = in.read(b);
                if (i == -1) {
                    break;
                }
                out.write(b, 0, i);
            }
            return out.toByteArray();
        }
    };
}
项目:BilibiliClient    文件:BiliDanmukuCompressionTools.java   
public static byte[] decompress(byte[] value) throws DataFormatException {

    ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length);

    Inflater decompressor = new Inflater();

    try {
      decompressor.setInput(value);

      final byte[] buf = new byte[1024];
      while (!decompressor.finished()) {
        int count = decompressor.inflate(buf);
        bos.write(buf, 0, count);
      }
    } finally {
      decompressor.end();
    }

    return bos.toByteArray();
  }
项目:BilibiliClient    文件:BiliDanmukuCompressionTools.java   
public static byte[] decompress(byte[] value) throws DataFormatException {

    ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length);

    Inflater decompressor = new Inflater();

    try {
      decompressor.setInput(value);

      final byte[] buf = new byte[1024];
      while (!decompressor.finished()) {
        int count = decompressor.inflate(buf);
        bos.write(buf, 0, count);
      }
    } finally {
      decompressor.end();
    }

    return bos.toByteArray();
  }
项目:Towan    文件:PNGDecoder.java   
private void readChunkUnzip(Inflater inflater, byte[] buffer, int offset, int length) throws IOException {
    try {
        do {
            int read = inflater.inflate(buffer, offset, length);
            if(read <= 0) {
                if(inflater.finished()) {
                    throw new EOFException();
                }
                if(inflater.needsInput()) {
                    refillInflater(inflater);
                } else {
                    throw new IOException("Can't inflate " + length + " bytes");
                }
            } else {
                offset += read;
                length -= read;
            }
        } while(length > 0);
    } catch (DataFormatException ex) {
        throw (IOException)(new IOException("inflate error").initCause(ex));
    }
}
项目:openjdk-jdk10    文件:ZipDecompressor.java   
static byte[] decompress(byte[] bytesIn, int offset) throws Exception {
    Inflater inflater = new Inflater();
    inflater.setInput(bytesIn, offset, bytesIn.length - offset);
    ByteArrayOutputStream stream = new ByteArrayOutputStream(bytesIn.length - offset);
    byte[] buffer = new byte[1024];

    while (!inflater.finished()) {
        int count = inflater.inflate(buffer);
        stream.write(buffer, 0, count);
    }

    stream.close();

    byte[] bytesOut = stream.toByteArray();
    inflater.end();

    return bytesOut;
}
项目:discord.jar    文件:WebSocketClient.java   
@Override
public void onMessage(ByteBuffer message) {
    try {

        //Thanks to ShadowLordAlpha for code and debugging.
        //Get the compressed message and inflate it
        StringBuilder builder = new StringBuilder();
        Inflater decompresser = new Inflater();
        byte[] bytes = message.array();
        decompresser.setInput(bytes, 0, bytes.length);
        byte[] result = new byte[128];
        while (!decompresser.finished()) {
            int resultLength = decompresser.inflate(result);
            builder.append(new String(result, 0, resultLength, "UTF-8"));
        }
        decompresser.end();

        // send the inflated message to the TextMessage method
        onMessage(builder.toString());
    } catch (DataFormatException | UnsupportedEncodingException e) {
        e.printStackTrace();
    }
}
项目:cas4.0.x-server-wechat    文件:FrontChannelLogoutActionTests.java   
@Test
public void testLogoutOneLogoutRequestNotAttempted() throws Exception {
    final String FAKE_URL = "http://url";
    LogoutRequest logoutRequest = new LogoutRequest(TICKET_ID, new SimpleWebApplicationServiceImpl(FAKE_URL));
    WebUtils.putLogoutRequests(this.requestContext, Arrays.asList(logoutRequest));
    this.requestContext.getFlowScope().put(FrontChannelLogoutAction.LOGOUT_INDEX, 0);
    final Event event = this.frontChannelLogoutAction.doExecute(this.requestContext);
    assertEquals(FrontChannelLogoutAction.REDIRECT_APP_EVENT, event.getId());
    List<LogoutRequest> list = WebUtils.getLogoutRequests(this.requestContext);
    assertEquals(1, list.size());
    final String url = (String) event.getAttributes().get("logoutUrl");
    assertTrue(url.startsWith(FAKE_URL + "?SAMLRequest="));
    final byte[] samlMessage = Base64.decodeBase64(URLDecoder.decode(StringUtils.substringAfter(url,  "?SAMLRequest="), "UTF-8"));
    final Inflater decompresser = new Inflater();
    decompresser.setInput(samlMessage);
    final byte[] result = new byte[1000];
    decompresser.inflate(result);
    decompresser.end();
    final String message = new String(result);
    assertTrue(message.startsWith("<samlp:LogoutRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\""));
    assertTrue(message.indexOf("<samlp:SessionIndex>" + TICKET_ID + "</samlp:SessionIndex>") >= 0);
}
项目:IO    文件:CompressionTask.java   
/**
   * Testing method for decompression of ewf file hex bytes
   * @param ewfHexStr any zlib compressed hex
   * @return decompressed string
   */
  protected static String decompress(String ewfHexStr) {
Inflater inflater = new Inflater();
byte[] input = DatatypeConverter.parseHexBinary(ewfHexStr);
inflater.setInput(input, 0, input.length);
String outputString = "empty";

byte[] result = new byte[input.length];
int resultLength;
try {
    resultLength = inflater.inflate(result);
    outputString = new String(result, 0, resultLength, "UTF-8");
} catch (DataFormatException | UnsupportedEncodingException e) {
    e.printStackTrace();
}
inflater.end();

return outputString;
  }
项目:oscm    文件:RedirectSamlURLBuilderTest.java   
private String decodeURLBase64DeflateString(final String input)
        throws UnsupportedEncodingException, DataFormatException {
    String urlDecoded = URLDecoder.decode(input, "UTF-8");
    byte[] base64Decoded = Base64.decodeBase64(urlDecoded);

    Inflater decompresser = new Inflater(true);
    decompresser.setInput(base64Decoded);
    StringBuilder result = new StringBuilder();

    while (!decompresser.finished()) {
        byte[] outputFraction = new byte[base64Decoded.length];
        int resultLength = decompresser.inflate(outputFraction);
        result.append(new String(outputFraction, 0, resultLength, "UTF-8"));
    }

    return result.toString();
}
项目:compress    文件:DeflaterCompress.java   
@Override
public byte[] uncompress(byte[] data) throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    Inflater decompressor = new Inflater();

    try {
        decompressor.setInput(data);
        final byte[] buf = new byte[2048];
        while (!decompressor.finished()) {
            int count = decompressor.inflate(buf);
            bos.write(buf, 0, count);
        }
    } catch (DataFormatException e) {
        e.printStackTrace();
    } finally {
        decompressor.end();
    }

    return bos.toByteArray();
}
项目:letv    文件:bs.java   
public static byte[] b(byte[] bArr) throws UnsupportedEncodingException, DataFormatException {
    int i = 0;
    if (bArr == null || bArr.length == 0) {
        return null;
    }
    Inflater inflater = new Inflater();
    inflater.setInput(bArr, 0, bArr.length);
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    byte[] bArr2 = new byte[1024];
    while (!inflater.needsInput()) {
        int inflate = inflater.inflate(bArr2);
        byteArrayOutputStream.write(bArr2, i, inflate);
        i += inflate;
    }
    inflater.end();
    return byteArrayOutputStream.toByteArray();
}
项目:cas-server-4.2.1    文件:FrontChannelLogoutActionTests.java   
@Test
public void verifyLogoutOneLogoutRequestNotAttempted() throws Exception {
    final SingleLogoutService service = new WebApplicationServiceFactory().createService(TEST_URL, SingleLogoutService.class);
    final LogoutRequest logoutRequest = new DefaultLogoutRequest(TICKET_ID,
            service,
            new URL(TEST_URL));
    final Event event = getLogoutEvent(Arrays.asList(logoutRequest));

    assertEquals(FrontChannelLogoutAction.REDIRECT_APP_EVENT, event.getId());
    final List<LogoutRequest> list = WebUtils.getLogoutRequests(this.requestContext);
    assertEquals(1, list.size());
    final String url = (String) event.getAttributes().get(FrontChannelLogoutAction.DEFAULT_FLOW_ATTRIBUTE_LOGOUT_URL);
    assertTrue(url.startsWith(TEST_URL + '?' + FrontChannelLogoutAction.DEFAULT_LOGOUT_PARAMETER + '='));
    final byte[] samlMessage = CompressionUtils.decodeBase64ToByteArray(
            URLDecoder.decode(StringUtils.substringAfter(url, '?' + FrontChannelLogoutAction.DEFAULT_LOGOUT_PARAMETER + '='), "UTF-8"));
    final Inflater decompresser = new Inflater();
    decompresser.setInput(samlMessage);
    final byte[] result = new byte[1000];
    decompresser.inflate(result);
    decompresser.end();
    final String message = new String(result);
    assertTrue(message.startsWith("<samlp:LogoutRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\""));
    assertTrue(message.contains("<samlp:SessionIndex>" + TICKET_ID + "</samlp:SessionIndex>"));
}
项目:fpm    文件:PbfBlobDecoder.java   
public static byte[] inflate(PbfRawBlob rawBlob) throws InvalidProtocolBufferException {
    Blob blob = Blob.parseFrom(rawBlob.getData());
    byte[] blobData;
    if (blob.hasRaw()) {
        blobData = blob.getRaw().toByteArray();
    }
    else if (blob.hasZlibData()) {
        Inflater inflater = new Inflater();
        inflater.setInput(blob.getZlibData().toByteArray());
        blobData = new byte[blob.getRawSize()];
        try {
            inflater.inflate(blobData);
        }
        catch (DataFormatException e) {
            throw new OsmosisRuntimeException("Unable to decompress PBF blob.", e);
        }
        if (!inflater.finished()) {
            throw new OsmosisRuntimeException("PBF blob contains incomplete compressed data.");
        }
    }
    else {
        throw new OsmosisRuntimeException("PBF blob uses unsupported compression, only raw or zlib may be used.");
    }
    return blobData;
}
项目:monarch    文件:CliUtil.java   
public static DeflaterInflaterData uncompressBytes(byte[] output, int compressedDataLength)
    throws DataFormatException {
  Inflater decompresser = new Inflater();
  decompresser.setInput(output, 0, compressedDataLength);
  byte[] buffer = new byte[512];
  byte[] result = new byte[0];
  int bytesRead;
  while (!decompresser.needsInput()) {
    bytesRead = decompresser.inflate(buffer);
    byte[] newResult = new byte[result.length + bytesRead];
    System.arraycopy(result, 0, newResult, 0, result.length);
    System.arraycopy(buffer, 0, newResult, result.length, bytesRead);
    result = newResult;
  }
  // System.out.println(new String(result));
  decompresser.end();

  return new DeflaterInflaterData(result.length, result);
}
项目:trashjam2017    文件:PNGDecoder.java   
private void refillInflater(Inflater inflater) throws IOException {
    while(chunkRemaining == 0) {
        closeChunk();
        openChunk(IDAT);
    }
    int read = readChunk(buffer, 0, buffer.length);
    inflater.setInput(buffer, 0, read);
}
项目:parabuild-ci    文件:ScriptReaderZipped.java   
protected void openFile() throws IOException {

        InputStream d = db.isFilesInJar()
                        ? getClass().getResourceAsStream(fileName)
                        : db.getFileAccess().openInputStreamElement(fileName);

        dataStreamIn = new DataInputStream(
            new BufferedInputStream(
                new InflaterInputStream(d, new Inflater()), 1 << 13));
    }
项目:q-mail    文件:MockImapServer.java   
private void enableCompression(Socket socket) throws IOException {
    InputStream inputStream = new InflaterInputStream(socket.getInputStream(), new Inflater(true));
    input = Okio.buffer(Okio.source(inputStream));

    ZOutputStream outputStream = new ZOutputStream(socket.getOutputStream(), JZlib.Z_BEST_SPEED, true);
    outputStream.setFlushMode(JZlib.Z_PARTIAL_FLUSH);
    output = Okio.buffer(Okio.sink(outputStream));
}
项目:q-mail    文件:MockPop3Server.java   
private void enableCompression(Socket socket) throws IOException {
    InputStream inputStream = new InflaterInputStream(socket.getInputStream(), new Inflater(true));
    input = Okio.buffer(Okio.source(inputStream));

    ZOutputStream outputStream = new ZOutputStream(socket.getOutputStream(), JZlib.Z_BEST_SPEED, true);
    outputStream.setFlushMode(JZlib.Z_PARTIAL_FLUSH);
    output = Okio.buffer(Okio.sink(outputStream));
}
项目:NotiCap    文件:Compressor.java   
static byte[] decompress(byte[] data) throws IOException, DataFormatException {
    Inflater inflater = new Inflater(true);
    inflater.setInput(data);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
    byte[] buffer = new byte[1024];
    while (!inflater.finished()) {
        int count = inflater.inflate(buffer);
        outputStream.write(buffer, 0, count);
    }
    outputStream.close();
    byte[] output = outputStream.toByteArray();
    Log.d("Compressor", "Original: " + data.length);
    Log.d("Compressor", "Decompressed: " + output.length);
    return output;
}
项目:framework    文件:InflaterInputStream.java   
/**
 * Creates a new input stream with the specified decompressor and
 * buffer size.
 *
 * @param in   the input stream
 * @param inf  the decompressor ("inflater")
 * @param size the input buffer size
 * @throws IllegalArgumentException if size is <= 0
 */
public InflaterInputStream(InputStream in, Inflater inf, int size) {
    super(in);
    if (in == null || inf == null) {
        throw new NullPointerException();
    } else if (size <= 0) {
        throw new IllegalArgumentException("buffer size <= 0");
    }
    this.inf = inf;
    buf = new byte[size];
}
项目:Cubes    文件:SocketInput.java   
public SocketInput(SocketMonitor socketMonitor) {
  super(socketMonitor);
  this.socketInputStream = socketMonitor.getSocket().getInputStream();
  this.dataInputStream = new DataInputStream(socketInputStream) {
    @Override
    public void close() throws IOException {
      //prevents being closed by packets
    }
  };

  this.inflater = new Inflater(SocketOutput.COMPRESSION_NOWRAP);
  this.pairedStreams = new PairedStreams();
}
项目:sstore-soft    文件:ScriptReaderZipped.java   
protected void openFile() throws IOException {

        InputStream d = db.isFilesInJar()
                        ? getClass().getResourceAsStream(fileName)
                        : db.getFileAccess().openInputStreamElement(fileName);

        dataStreamIn = new DataInputStream(
            new BufferedInputStream(
                new InflaterInputStream(d, new Inflater()), 1 << 13));
    }
项目:mobile-store    文件:ZioEntry.java   
public InputStream getInputStream(OutputStream monitorStream) throws IOException {

    if (entryOut != null) {
        entryOut.close();
        size = entryOut.getSize();
        data = ((ByteArrayOutputStream)entryOut.getWrappedStream()).toByteArray();
        compressedSize = data.length;
        crc32 = entryOut.getCRC();
        entryOut = null;
        InputStream rawis = new ByteArrayInputStream( data);
        if (compression == 0) return rawis;
        else {
            // Hacky, inflate using a sequence of input streams that returns 1 byte more than the actual length of the data.  
            // This extra dummy byte is required by InflaterInputStream when the data doesn't have the header and crc fields (as it is in zip files). 
            return new InflaterInputStream( new SequenceInputStream(rawis, new ByteArrayInputStream(new byte[1])), new Inflater( true));
        }
    }

    ZioEntryInputStream dataStream;
    dataStream = new ZioEntryInputStream(this);
    if (monitorStream != null) dataStream.setMonitorStream( monitorStream);
    if (compression != 0)  {
        // Note: When using nowrap=true with Inflater it is also necessary to provide 
        // an extra "dummy" byte as input. This is required by the ZLIB native library 
        // in order to support certain optimizations.
        dataStream.setReturnDummyByte(true);
        return new InflaterInputStream( dataStream, new Inflater( true));
    }
    else return dataStream;
}
项目:boohee_v5.6    文件:GzipSource.java   
public GzipSource(Source source) {
    if (source == null) {
        throw new IllegalArgumentException("source == null");
    }
    this.inflater = new Inflater(true);
    this.source = Okio.buffer(source);
    this.inflaterSource = new InflaterSource(this.source, this.inflater);
}
项目:BibliotecaPS    文件:CompressedInputStream.java   
/**
 * Creates a new CompressedInputStream that reads the given stream from the
 * server.
 * 
 * @param conn
 * @param streamFromServer
 */
public CompressedInputStream(Connection conn, InputStream streamFromServer) {
    this.traceProtocol = ((ConnectionPropertiesImpl) conn).traceProtocol;
    try {
        this.log = conn.getLog();
    } catch (SQLException e) {
        this.log = new NullLogger(null);
    }

    this.in = streamFromServer;
    this.inflater = new Inflater();
}
项目:Crunched    文件:Utils.java   
public static byte[] decompressZlib(byte[] input) {
    try {
        Inflater decompress = new Inflater();
        decompress.setInput(input);
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        InflaterOutputStream inflaterOutputStream = new InflaterOutputStream(byteArrayOutputStream, decompress);
        inflaterOutputStream.flush();
        return byteArrayOutputStream.toByteArray();
    } catch (Exception e) {
        System.out.println("An error occured while decompressing data");
        System.exit(-2);
    }
    return null;
}