Java examples for File Path IO:Zip File
compress To File
//package com.java2s; import java.io.*; import java.util.zip.GZIPOutputStream; public class Main { public static void compressToFile(File dest, String str) throws IOException { if (str == null) { return; }//from ww w . ja v a 2s . c o m GZIPOutputStream zipOut = null; try { zipOut = new GZIPOutputStream(new FileOutputStream(dest)); zipOut.write(str.getBytes()); } finally { if (zipOut != null) { try { zipOut.close(); } catch (IOException e) { e.printStackTrace(); } } } } }