Java 8 ですが、こんな感じで空zipができました。ZipEntryは使わず、単にZipOutputStreamを開けて閉じただけです。
java
1import java.io.*;
2import java.util.zip.*;
3
4public class Teratail45612 {
5 public static void main(String... args) {
6 try(ZipOutputStream zos =
7 new ZipOutputStream(
8 new FileOutputStream(
9 new File("empty.zip")))) {
10 // do nothing;
11 }
12 }
13}
bash
1$ od -t cx1 empty.zip
20000000 P K 005 006 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
3 50 4b 05 06 00 00 00 00 00 00 00 00 00 00 00 00
40000020 \0 \0 \0 \0 \0 \0
5 00 00 00 00 00 00
60000026
PK\05\06
はZIPファイルの最後のブロックを意味します。
参考: https://support.pkware.com/display/PKZIP/APPNOTE
なにも情報を持っていないZipファイルは常に上記のバイト列になるので、単に OutputStream で書くだけでも作れます。こんなかんじ?
java
1 public static void main(String... args) throws Exception {
2 int[] emptyzip = new int[] { 'P', 'K', 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
3 try(OutputStream os = new FileOutputStream(new File("empty.zip"))) {
4 for(int b: emptyzip) { os.write(b); }
5 }
6 }