Windows(7)でファイルを.zipで圧縮したいZipOutputStream
。問題は、ファイル名 (およびファイル ファイルの内容も) にギリシャ文字 (" ГП0000660040140521_a.txt
"、ガンマ、パイ) が含まれていることです。私が使用するファイルを圧縮するコード:
ZipOutputStream zipOs = new ZipOutputStream(
new FileOutputStream("c:\\temp\\test.zip"), Charset.forName("cp737")
);
File sourceFile = new File("C:/Path/To/File/ГП0000660040140521_b.txt");
String entryName = sourceFile.getName().replaceAll("\\\\", "/");
ZipEntry entry = new ZipEntry(entryName);
zipOs.putNextEntry(entry);
...
...
しかし、最後の行(putNextEntry
呼び出し)で次のようになりますIllegalArgumentException
:
java.lang.IllegalArgumentException: UNMAPPABLE[1]
at java.util.zip.ZipCoder.getBytes(ZipCoder.java:95)
at java.util.zip.ZipOutputStream.writeLOC(ZipOutputStream.java:407)
at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:221)
ギリシャ語と UTF-8 の間の文字マッピングに何か問題があるに違いないと思います...ファイル名にギリシャ文字を含むファイルを圧縮する正しい方法は何ですか?
編集
文字セットとして「utf-8」を使用すると、zip ファイルを作成できますが、圧縮されたファイルの名前が間違っています:「ðôðƒ0000660040140521_a.txt
」(ギリシャ文字がありません)