MCPcopy
hub / github.com/google/brotli / decompress

Method decompress

java/org/brotli/dec/DecodeTest.java:25–51  ·  view source on GitHub ↗
(byte[] data, boolean byByte)

Source from the content-addressed store, hash-verified

23public class DecodeTest {
24
25 private byte[] decompress(byte[] data, boolean byByte) throws IOException {
26 byte[] buffer = new byte[65536];
27 ByteArrayInputStream input = new ByteArrayInputStream(data);
28 ByteArrayOutputStream output = new ByteArrayOutputStream();
29 InputStream brotliInput = newBrotliInputStream(input);
30 if (byByte) {
31 byte[] oneByte = new byte[1];
32 while (true) {
33 int next = brotliInput.read();
34 if (next == -1) {
35 break;
36 }
37 oneByte[0] = (byte) next;
38 output.write(oneByte, 0, 1);
39 }
40 } else {
41 while (true) {
42 int len = brotliInput.read(buffer, 0, buffer.length);
43 if (len <= 0) {
44 break;
45 }
46 output.write(buffer, 0, len);
47 }
48 }
49 brotliInput.close();
50 return output.toByteArray();
51 }
52
53 private void checkDecodeResource(String expected, String compressed) throws IOException {
54 byte[] expectedBytes = readUniBytes(expected);

Callers 1

checkDecodeResourceMethod · 0.95

Calls 4

newBrotliInputStreamMethod · 0.80
readMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected