byte[] buf = new byte[1024];//time to make zip file
String zipName="name.zip";
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipName));
for(int i=0; i<copy.length; i++){//put all pdfs in the zip
FileInputStream zipFile = new FileInputStream(copy[i]);
out.putNextEntry(new ZipEntry(copy[i]));
int len;
while((len=zipFile.read(buf))>0){
out.write(buf, 0, len);
}
out.closeEntry();
zipFile.close();
}
out.close();
copy は、必要な各ファイルのファイル パスを含む文字列の配列です (たとえば、C:\files\test.pdf)。例外なく正常にコンパイルおよび実行され、zip フォルダーが作成されますが、その zip フォルダーには何もありません。