开发者

ZipInputStream Throws Illegalargument exception for diacritics

开发者 https://www.devze.com 2023-01-19 01:30 出处:网络
If I run the below program with the zip file which has some files with diacritic characters (e.g 1-2GF-969##JÖN.pdf) , I get IllegalArgumentException.

If I run the below program with the zip file which has some files with diacritic characters (e.g 1-2GF-969##JÖN.pdf) , I get IllegalArgumentException.

My application has to support all languages. So, we set encoding to UTF-8

All languages work fine. But the problem comes when 开发者_Go百科reading diacritic characters.

I tried using alternatives to zip input stream, like arcmexer, but it does not support Chinese characters.

Please help me with this.

  private static void readUsingJava() {
        ZipInputStream zis;
        try {
              zis = new ZipInputStream(new FileInputStream("C:\\Check.zip"));
              ZipEntry ze;
              while ((ze = zis.getNextEntry()) != null) {
                    System.out.println("Name of the File Is  :: " + ze.getName());
              }
              zis.close();
        } catch (FileNotFoundException e) {
              e.printStackTrace();
        } catch (IOException e) {
              e.printStackTrace();
        }
  }


Most likely the ZIP archives you tried this with don't use UTF-8 encoding. This article should help: http://commons.apache.org/compress/zip.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号