Java GZip gzip(String s)

Here you can find the source of gzip(String s)

Description

gzip

License

Open Source License

Declaration

public static byte[] gzip(String s) throws Exception 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayOutputStream;

import java.io.OutputStreamWriter;

import java.nio.charset.StandardCharsets;

import java.util.zip.GZIPOutputStream;

public class Main {
    public static byte[] gzip(String s) throws Exception {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        GZIPOutputStream gzip = new GZIPOutputStream(bos);
        OutputStreamWriter osw = new OutputStreamWriter(gzip, StandardCharsets.UTF_8);
        osw.write(s);//  www  .  j av  a  2s  .c  o  m
        osw.close();
        return bos.toByteArray();
    }
}

Related

  1. gzip(final T o)
  2. gzip(String str)
  3. gzipDecompress(byte[] compressed)
  4. gzipFileReader(String file)
  5. gzipReader(final InputStream inputStream)