I want to zip a file on Windows (7) with ZipOutputStream
. The Problem is that the file name (and file file Content too) contains also Greek characters ("ГП0000660040140521_a.txt
", Gamma and Pi). The code to zip the file I use:
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);
...
...
But on the last line (the putNextEntry
call) I get a 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)
I assume there must be anything wrong with the character mapping between Greek and UTF-8 ... Whats the right way to zip a file with Greek characters in the file Name?
EDIT
If I use "utf-8" as character set the zip file can be created, but the name of the zipped file is wrong: "ðôðƒ0000660040140521_a.txt
" (the Greek characters are missing)