Here you can find the source of zip_Str(String in_str)
public static byte[] zip_Str(String in_str)
//package com.java2s; /**//from www . j a v a2s. com * Copyright (c) 2014 http://www.lushapp.wang * * Licensed under the Apache License, Version 2.0 (the "License"); */ import java.io.*; import java.util.*; import java.util.zip.Deflater; public class Main { public static byte[] zip_Str(String in_str) { byte[] input = new byte[0]; try { input = in_str.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } ArrayList<Byte> al = new ArrayList<Byte>(); byte[] output; Deflater compresser = new Deflater(); compresser.setInput(input); compresser.finish(); for (; !compresser.finished();) { output = new byte[100]; compresser.deflate(output); for (int i = 0; i < output.length; i++) { al.add(new Byte(output[i])); } } output = new byte[al.size()]; for (int i = 0; i < al.size(); i++) { output[i] = (al.get(i)).byteValue(); } return output; } }