JAvaはZIPファイルを作成


コードクリップ:
さんは臨時ファイルZIPファイルになります.
ZipOutputStream zos = null;
BufferedInputStream bis = null;
byte[] buffer = new byte[1024];
//     
zos = new ZipOutputStream(new FileOutputStream("/temp"+ "/Archive.zip"));

ZIPファイルにファイルデータを書きます.
File folder = new File("/source");
for (File file : folder.listFiles()) {
	zos.putNextEntry(new ZipEntry("source" + "/" + file.getName()));   //    source   。
	bis = new BufferedInputStream(new FileInputStream(file));
	while ((bis.read(buffer)) != -1) {
		zos.write(buffer);
        buffer = new byte[1024]; //   text file     
     }

        zos.flush();   //closeEntry     。      
        zos.closeEntry();
	bis.close();
}

最後にファイルフローを閉じます.
zos.close();
Java.util.zip.ZipOutputStreamを使用すると、ファイル名はutf-8の形式で自動的に使用されます.これで中国語名とかで文字化けしてしまう.
org.apache.tools.zip.ZipOutputStreamに変更し、setEncodigメソッドでエンコードを設定すると文字化けしが解決します.