java - String to GZIPOutputStream -
i've tried searching , couldn't find anything. i'm trying i'm looping through list i'm constructing string combination of items multiple lists. want dump these strings gzipped file. got working dumping plain ascii text file can't seem work gzipoutputstream. basically,
loop create string dump string gzipped file endloop
if possible, i'd avoid dumping plain text file gzipping since these files 100 meg each.
yes, can no problem. need use writer convert character based strings 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" }; (string line : data) { writer.append(line); writer.newline(); } } { if (writer != null) writer.close(); } also, remember gzip compresses stream, if want embeded files, see post: gzip archive multiple files inside
Comments
Post a Comment