Java: Error creating a GZIPInputStream: Not in GZIP format
问题 I am trying to use the following Java code to compress and uncompress a String. But the line that creates a new GZipInputStream object out of a new ByteArrayInputStream object throws a "java.util.zip.ZipException: Not in GZIP format" exception. Does anyone know how to solve this? String orig = "............."; // compress it ByteArrayOutputStream baostream = new ByteArrayOutputStream(); OutputStream outStream = new GZIPOutputStream(baostream); outStream.write(orig.getBytes()); outStream.close