Java Zip String zipString(String str)

Here you can find the source of zipString(String str)

Description

zip String

License

Open Source License

Declaration

public static String zipString(String str) throws IOException 

Method Source Code

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

import java.io.ByteArrayOutputStream;

import java.io.IOException;

import java.util.zip.GZIPOutputStream;

public class Main {
    public static String zipString(String str) throws IOException {
        if (str == null || str.length() == 0) {
            return str;
        }//www .  j  a  v a2  s.co m
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        GZIPOutputStream gzip = new GZIPOutputStream(out);
        gzip.write(str.getBytes());
        gzip.close();
        return out.toString("ISO-8859-1");
    }
}

Related

  1. zip(String content)
  2. zip(String str)
  3. zip(String toCompress)
  4. zip_Str(String in_str)
  5. zipString(String input)
  6. zipStringAsFile(String contents, File destZipFile, String internalFilename, String comment)
  7. zipStringToBytes(String input)
  8. zipText(String text)