Java Utililty Methods Zip String

List of utility methods to do Zip String

Description

The list of methods to do Zip String are organized into topic(s).

Method

voidaddStringToZip(String text, String entryName, ZipOutputStream zOut)
Adds a String as a field entry to an already opened ZipOutputStream
BufferedReader reader = new BufferedReader(new StringReader(text));
ZipEntry zipEntry = new ZipEntry(entryName);
zOut.putNextEntry(zipEntry);
int i;
while ((i = reader.read()) != -1) {
    zOut.write(i);
zOut.closeEntry();
...
ByteArrayOutputStreamgenerateZip(String kmlContents)
zips the contents of the string passed in into a file called "waterforpeoplemapping.kml"
return generateZip(kmlContents, "waterforpeoplemapping.kml");
byte[]zip(String content)
zip
return zip("name", content);
byte[]zip(String content)
Method zip
return deflate(content.getBytes());
Stringzip(String str)
zip
if (str == null)
    return null;
byte[] compressed;
ByteArrayOutputStream out = null;
ZipOutputStream zout = null;
String compressedStr = null;
try {
    out = new ByteArrayOutputStream();
...
Stringzip(String toCompress)
zip
ZipOutputStream zos = null;
try {
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final byte[] ba = toCompress.getBytes();
    zos = new ZipOutputStream(out);
    zos.setLevel(5);
    zos.setMethod(ZipOutputStream.DEFLATED);
    final ZipEntry ze = new ZipEntry("result");
...
byte[]zip_Str(String in_str)
zi 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;
...
byte[]zipString(String input)
Zips a string input to compressed bytes
try {
    byte[] uncompressedBytes = input.getBytes("UTF-8");
    return zip(uncompressedBytes);
} catch (Exception e) {
    if ("true".equals(System.getProperty("de.innovationgate.wga.debug.zipping"))) {
        e.printStackTrace();
    return null;
...
StringzipString(String str)
zip String
if (str == null || str.length() == 0) {
    return str;
ByteArrayOutputStream out = new ByteArrayOutputStream();
GZIPOutputStream gzip = new GZIPOutputStream(out);
gzip.write(str.getBytes());
gzip.close();
return out.toString("ISO-8859-1");
...
voidzipStringAsFile(String contents, File destZipFile, String internalFilename, String comment)
zip String As File
int BUFFER = 2048;
byte data[] = new byte[BUFFER];
BufferedInputStream origin = null;
FileOutputStream dest = new FileOutputStream(destZipFile);
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
ByteArrayInputStream fi = new ByteArrayInputStream(contents.getBytes());
origin = new BufferedInputStream(fi, BUFFER);
ZipEntry entry = new ZipEntry(internalFilename);
...