Search in sources :

Example 1 with ChunkedInputStream

use of org.apache.commons.httpclient.ChunkedInputStream in project kcanotify by antest1.

the class KcaUtils method unchunkdata.

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;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ChunkedInputStream(org.apache.commons.httpclient.ChunkedInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ChunkedInputStream (org.apache.commons.httpclient.ChunkedInputStream)1