ZIP文件 - 使用Windows资源管理器打开时,条目名称编码不正确

时间:2016-06-17 09:56:31

标签: java compression

我使用以下代码创建一个zip文件:

public static void main(String[] args) {
    byte[] buffer = new byte[1024];
    String inputFilepath = "./src/main/resources/email-hule.html";
    String outputFilepath = "." + File.separator + "target" + File.separator + "ĐỨcNguyễn.zip";
    FileOutputStream fos = null;
    ZipOutputStream zos = null;
    try {
        fos = new FileOutputStream(outputFilepath);
        zos = new ZipOutputStream(fos);
        ZipEntry ze = new ZipEntry("Đức Nguyễn Văn.xml");
        zos.putNextEntry(ze);
        FileInputStream in = new FileInputStream(inputFilepath);

        int len;
        while ((len = in.read(buffer)) > 0) {
            zos.write(buffer, 0, len);
        }
        in.close();
        zos.closeEntry();
        //remember close it
        zos.close();
        System.out.println("Done");

    } catch (IOException ex) {
        ex.printStackTrace();
    } finally {

    }
}

完整代码here

如果我用7zip打开文件

Open Zipe file with 7zip

但我用Windows资源管理器打开文件 - Windows 7

Open Zipe file with Windows Explorer

我该如何纠正?

由于

0 个答案:

没有答案