javacsvoutlookunzipzipstream

Japanese filename is getting garbled while extracting


I am zipping a .csv file as follows:

fileInputStream = new FileInputStream(csvFile);
final ZipEntry zipEntry = new ZipEntry(csvFile.getname());
            zipOutputStream.putNextEntry(zipEntry);
            final byte[] buffer = new byte[4 * 1024];
            int size = fileInputStream.read(buffer);
            while (size != -1) 
        {
                zipOutputStream.write(buffer, 0, size);
                size = fileInputStream.read(buffer);
        }       

The filename also contains japanese/chinese characters On extracting with winzip/ 7-zip the extracted .csv file name is not garbled but when default windows extracter is used the filename is garbled.


Solution

  • I had used :

    String fileName = MimeUtility.encodeText(filename,"SJIS",null);

    and then it seemed to work fine on systems where the default language was japanese.