List of utility methods to do GZip
byte[] | gzip(final T o) passed object convert to gziped byte array. if (o == null) { return null; try (final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final GZIPOutputStream gzip = new GZIPOutputStream(baos);) { gzip.write(MAPPER.writeValueAsBytes(o)); ; gzip.close(); ... |
byte[] | gzip(String s) gzip ByteArrayOutputStream bos = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(bos); OutputStreamWriter osw = new OutputStreamWriter(gzip, StandardCharsets.UTF_8); osw.write(s); osw.close(); return bos.toByteArray(); |
String | gzip(String str) gzip if (null == str || str.length() < 1) { return str; ByteArrayOutputStream out = new ByteArrayOutputStream(); try (GZIPOutputStream gzip = new GZIPOutputStream(out)) { gzip.write(str.getBytes()); return out.toString(CHARSET_ZIP.name()); ... |
String | gzipDecompress(byte[] compressed) gzip Decompress byte[] bytes = gzipDecompressBytes(compressed); return new String(bytes, StandardCharsets.UTF_8); |
BufferedReader | gzipFileReader(String file) gzip File Reader return new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(file)), UTF8)); |
BufferedReader | gzipReader(final InputStream inputStream) gzip Reader return reader(new GZIPInputStream(inputStream)); |
byte[] | gzipString(String src, byte default_value[]) gzip String if (src == null) return default_value; return gzip(src.getBytes(utf8), default_value); |