String to GZIPOutputStream
Yes, you can do this no problem. You just need to use a writer to convert from your character based strings to the byte based gzip stream.
BufferedWriter writer = null;
try {
GZIPOutputStream zip = new GZIPOutputStream(
new FileOutputStream(new File("tmp.zip")));
writer = new BufferedWriter(
new OutputStreamWriter(zip, "UTF-8"));
String[] data = new String[] { "this", "is", "some",
"data", "in", "a", "list" };
for (String line : data) {
writer.append(line);
writer.newLine();
}
} finally {
if (writer != null)
writer.close();
}
Also, remember gzip just compresses a stream, if you want embeded files, see this post: gzip archive with multiple files inside