Java 类org.apache.commons.httpclient.ChunkedInputStream 实例源码

项目:kcanotify    文件:KcaUtils.java   
public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
    byte[] unchunkedData = null;
    byte[] buffer = new byte[1024];
    ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
    ChunkedInputStream cis = new ChunkedInputStream(bis);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    int read = -1;
    while ((read = cis.read(buffer)) != -1) {
        bos.write(buffer, 0, read);
    }
    unchunkedData = bos.toByteArray();
    bos.close();

    return unchunkedData;
}
项目:vso-intellij    文件:LogDecoder.java   
private static String tryUnzip(byte[] zipped) {
  try {
    ByteArrayInputStream is = new ByteArrayInputStream(zipped);
    ChunkedInputStream cs = new ChunkedInputStream(is);
    GZIPInputStream zs = new GZIPInputStream(cs);
    BufferedReader r = new BufferedReader(new InputStreamReader(zs));
    StringBuilder result = new StringBuilder();
    String line;
    while ((line = r.readLine()) != null) {
      result.append(line).append("\n");
    }
    return result.toString();
  }
  catch (IOException e) {
    if (!"Not in GZIP format".equals(e.getMessage())) {
      e.printStackTrace();
    }
    return null;
  }
}
项目:webarchive-commons    文件:Recorder.java   
/**
 * Get a raw replay of the 'entity'. For the common case of 
 * HTTP, this is the message-body after any (usually-unnecessary)
 * transfer-decoding but before any content-encoding (eg gzip) decoding
 * 
 * @return A replay input stream.
 * @throws IOException
 */
public InputStream getEntityReplayInputStream() throws IOException {
    if(inputIsChunked) {
        return new ChunkedInputStream(getRecordedInput().getMessageBodyReplayInputStream());
    } else {
        return getRecordedInput().getMessageBodyReplayInputStream();
    }
}