, , Oracle JRE:
private static byte[] unchunk(byte[] content) throws IOException {
ByteArrayInputStream bais = new ByteArrayInputStream(content);
ChunkedInputStream cis = new ChunkedInputStream(bais, new HttpClient() {}, null);
return readFully(cis);
}
sun.net.www.http.ChunkedInputStream, java.net.HttpURLConnection, .
This implementation does not provide detailed exceptions (line numbers) in the wrong content format.
It works with Java 8, but may fail with the next version. You have been warned.
May be useful for prototyping.
You can choose any implementation readFullyfrom Convert InputStream to Byte Array in Java .
source
share