ReaderUtils { public static byte[] deflateGzip(byte[] inputBytes) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try (GZIPInputStream gzipInputStream = new GZIPInputStream( new ByteArrayInputStream(inputBytes))) { byte[] buffer = new byte[BYTE_BUFFER_CHUNK_SIZE]; while (gzipInputStream.available() == 1) { int size = gzipInputStream.read(buffer); if (size == -1) { break; } byteArrayOutputStream.write(buffer, 0, size); } return byteArrayOutputStream.toByteArray(); } }  static MmtfStructure getDataFromUrl(String pdbId); static MmtfStructure getDataFromUrl(String pdbId, boolean https, boolean reduced); static byte[] getByteArrayFromUrl(String pdbId); static byte[] getByteArrayFromUrl(String pdbId, boolean https, boolean reduced); static byte[] deflateGzip(byte[] inputBytes); static MmtfStructure getDataFromFile(Path filePath); static MmtfStructure getDataFromInputStream(InputStream inStream);  }
@Test public void testGzipDecompress() throws IOException { byte[] uncompressed = new byte[] {65, 66, 67, 68, 10}; byte[] compressed = new byte[] {31, (byte) 139, 8, 8, 45, (byte) 174, 15, 87, 0, 3, 109, 101, 46, 116, 120, 116, 0, 115, 116, 114, 118, (byte) 225, 2, 0, (byte) 212, 70, (byte) 176, (byte) 148, 5, 0, 0, 0}; assertArrayEquals(ReaderUtils.deflateGzip(compressed), uncompressed); }
@Test(expected=IOException.class) public void testGzipDecompressText() throws IOException { byte[] uncompressed = new byte[] {65, 66, 67, 68, 10}; ReaderUtils.deflateGzip(uncompressed); }