Having problems creating a zip file with Japanese language character names

I have a bunch of files with names in Japanese characters (also Chinese, Korean, Spanish etc, but this will do for an example). The encoding is Unicode.
I wish to be able to put them in a zip file, then extract them again using any old zip tool (WinZip,PKZip,7-Zip etc)
Trouble is, every time I do it, the files inside the zipfile end up with garbage character names. The contents of the files are fine, though.
I'm aware that there used to be a bug in the java.util.zip.* classes regarding character encodings (http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=5bd4fe01ad8a7b4ec89afef5005da?bug_id=4244499) but as far as I can see it's supposed to have been fixed I have also tried the ZipOutputStream class from apache which allows you to set the encoding manually - no luck there either (just many different varieties of garbage characters)
Test code below. What am I missing here?
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
public class ZipTest {
static String uniqueFileName = "西 純.txt";
public static void main(String[] args) {
try {
standardZip();
apacheZip();
} catch (IOException fe) {
System.out.println("problem in file - exception " + fe.getMessage());
public static void apacheZip() throws IOException {
String encoding = "";
File inputFile = new File(uniqueFileName);
FileReader reader = new FileReader(inputFile);
encoding = reader.getEncoding();
System.out.println("Using Apache - Encoding = " + encoding);
File zipFile = new File("apacheZip.zip");
org.apache.tools.zip.ZipOutputStream zipOutputStream = new org.apache.tools.zip.ZipOutputStream(
zipFile);
zipOutputStream.setEncoding(encoding);
org.apache.tools.zip.ZipEntry zipEntry = new org.apache.tools.zip.ZipEntry(uniqueFileName);
zipEntry.setSize(inputFile.length());
zipEntry.setTime(inputFile.lastModified());
zipOutputStream.putNextEntry(zipEntry);
int c = 0;
while (c >= 0) {
c = reader.read();
if (c >= 0) {
zipOutputStream.write(c);
zipOutputStream.closeEntry();
zipOutputStream.finish();
public static void standardZip() throws IOException {
String encoding = "";
File inputFile = new File(uniqueFileName);
FileReader reader = new FileReader(inputFile);
encoding = reader.getEncoding();
System.out.println("Using Java IO - Encoding = " + encoding);
File zipFile = new File("standardZip.zip");
FileOutputStream zipOut = new FileOutputStream(zipFile);
java.util.zip.ZipOutputStream zipOutputStream = new java.util.zip.ZipOutputStream(zipOut);
java.util.zip.ZipEntry zipEntry = new java.util.zip.ZipEntry(uniqueFileName);
zipEntry.setSize(inputFile.length());
zipEntry.setTime(inputFile.lastModified());
zipOutputStream.putNextEntry(zipEntry);
int c = 0;
while (c >= 0) {
c = reader.read();
if (c >= 0) {
zipOutputStream.write(c);
zipOutputStream.closeEntry();
zipOutputStream.finish();

Emma_Baillie wrote:
I have a bunch of files with names in Japanese characters (also Chinese, Korean, Spanish etc, but this will do for an example). The encoding is Unicode.
I wish to be able to put them in a zip file, then extract them again using any old zip tool (WinZip,PKZip,7-Zip etc)
Trouble is, every time I do it, the files inside the zipfile end up with garbage character names. The contents of the files are fine, though.This is becuase zip tool doesn't support unicode for zip entries. For example WinZip prior to 11.2 does not support Unicode characters in filenames. You need to look for the simillar information for other tools. You can find more on tools on their website.

Similar Messages

  • Problems creating/extracting ZIP files, anyone?

    Greetings,
    I am having some odd bugs with OSX in creating and extracting ZIP files.  I’m curious if anyone else has run across this or if anyone has any remedies to suggest.
    The issue is that when I extract a ZIP archive, the extracted files have their creation dates and modification dates changed from the original versions.  For example, I have a directory created in 2010 and all the files were created and last modified in 2010.  However, when I ZIP the directory and re-extract it, many of the file dates change.  Some files have the creation dates changed so to match the last modified date.  In other cases, both the creation date and modification date are changed to something later than both, perhaps the date the directory was ZIPed or the date the directory was extracted.  And some files don’t seem to have the dates changed. 
    I have tried various options, such as terminal, and third party programs (BetterZip, Keka, Stuffit, & Archiver to name a few) and they all seem to have some variation of this behavior.  I have tried creating the Zip with one program and extracting with the other, and still this behavior persists.  Different files seem to be affected with each combination of creating and extracting programs. 
    Another odd behavior was that I tried password protecting some directories with financial data, and OSX could create the ZIP file with the password, but OSX could not unzip the file with the password it created for some files.  In every case, third party program could unzip the files with the password created in the terminal command.  This seem to happen inconsistently. 
    I have tried creating a dummy account and tested it in that account, with similar results.
    I’ve read the man page for the command line version of ZIP to see if there is some -option to preserve dates, but found nothing.  The typical command looks like this:
    > zip -er filename.zip  sourceDir
    > unzip filename.zip
    File types include directories, PDFs, Text docs, Quicken files.  Ive tested other directories too with other file types.  It doesn’t seem to affect every file, but seems unpredictable.  Luckily, I still have the original uncompressed version of most directories.  But I really want to archive some directories and unarchive them when needed.  The dates matter to me because they are mostly financial files and I use the dates to know what versions were used for taxes and other things.  Also, if dates change, then backup programs start replacing the good backups with files with the corrupted dates. 
    I’d appreciate any suggestions or feedback.  I there some bug in the ZIP protocol?  Is there some bug in OSX file system that is corrupting the dates with the archive and unarchive process? 
    Thank you for any suggestions-
    OSX 10.9.5,
    MBPro 2012

    OK, sorry did not read it correctly.  Read the first sentance and quit.
    No, Bridge is just a browser.  You can extract more than one file at a time in Win. Explorer.  You have to do them individually, but can run multiple extractions at the same time.
    There are other zip/unzip programs out there.  I know the the CS6 beta a number of users could not open it with WinZip and used alternate product just fine.

  • Having problems opening a pdf file with reader 10/11 get error msg cannot open close reader and try again any ideas

    having problems opening a pdf file with reader 10/11 get error msg cannot open close reader and try again any ideas

    Hi George ,
    Is it happening with all the PDF' or any specific one?
    Could you please share the error message so that we can replicate at our end ?
    Try repairing reader  once and see if that fixes the issue.
    Launch Reader>Navigate to Help>Repair Adobe Reader Installation
    Regards
    Sukrit Dhingra

  • How can I create a zip file with LabVIEW?

    I would like to compress my data (ASCII format) to an archive.
    I use LVZlib.vi to compress and decompress data but I would like to be able to read the output file with a software archiver such as PowerArchiver/WinZIP.
    Someone knows how I can create a file compatible with zip or gz standard format, thanks !

    >> Yes but I have to install a special archiver (with ms-dos ommand line ability
    >> such as pkzip,arc,rar,arj...) on the computer where I install my LV application.
    Search for "gnu tools for windows" and get zip.exe, gzip.exe, bzip2.exe and others (even the source, if you like). These are about 50kB files that run in place (no installation) - easy to include in a distributed app. Oh, since I'm logged in I'll attach a couple, though I don't have the source on this machine).
    Attachments:
    bin.zip ‏67 KB

  • How can i create a zip-file with multiple volumes

    Hi,
    i've to zip a large file (250 MB and more). But the zip file shouldn't be greater than 5 MB, because i have to send the file via E-Mail. So i've thought, that the solution of this problem can be to zip the large file in smaller zip-files, which are multiple volumes of a zip-archive. I've searched very long in WWW, but didn't find something. Perhaps you can help.
    Sorry, about the bad english. :-)
    Timo Bunger

    Hi
    Who said your english is bad ?. OK, are you looking for compressing the 250 MB file in to multiple versions using a java program ?. If not, there is a shareware you can download and split the file into multiple parts by specifying size of each part. You can send these parts via email and the other person can combine these parts into a single file again.
    Find this @
    http://www.freedownloadscenter.com/Utilities/File_Splitting_Utilities/EzSplit.html
    You may need to read a bit about it on how to use.
    Thanks
    Srinivas

  • Having problems creating PDF from website with query-string URLs

    I have a website that I would like to create a PDF from. I am using the Create -> PDF from Web Page..., selecting the site's home page, and capturing 2 levels, with "stay on same path" and "stay on same server" checked in order to limit the scope of the crawl.
    Where the pages are at example.com/foo/ and example.com/foo/bar/, this works fine. However, where the pages are at example.com/foo/ and example.com/foo/?p=1, the page represented by the query string URL is not converted to the PDF.
    This is a problem, given that the site I want to archive as a PDF uses query strings for most of its pages.
    I have been able to individually convert a single query-string-based page into a PDF using this method, but doing this for every page on the site would be almost impossible given the sheer number of pages on the site.
    Is this a known issue? Is there a workaround other than separately capturing each page (which would be prohibitive effort)?
    I have tried this in both Acrobat Pro X and Acrobat Pro 9 for Mac, with the same results.

    Remember, Acrobat is a 32-bit application and as such cannot access all that 'extra' stuff.
    Be well...

  • Problems creating a jar file with eclipse

    "posted as well on the eclipse forum but who knows maybe some of you had same issue before"
    Hi Developers.
    My issue is this, i have some java files which i would like to export and use as .jar files.
    All files contains classes, the files all ends with .java extention and are contained into a java project.
    I've seen the Eclipse tutorial for this case which advise to use:
    Click on project>Export>java>jar file>Save as("verkiezingen")>Location("desktop")
    Indeed it seems successfull as i see on my desktop the .jar file and while exporting the final dialog box does not tell me "exported with warnings"
    I then try to import the jar within a project like so:
    Right click on project>Build Path> add external jar's>select jar
    all good so far as i see the new item "Referenced package" under the usual "JRE system library"
    If now, within the project i create a new class and start with import.verkiezingen;
    it gives me an error message saying "The import verkiezingen cannot be resolved"
    cant understand why, if i open the jar from the "Reference package" the classes are there.
    I will paste the code of a class within the project i've tried to export initially as jar.
    code:
    public class StemmachineException extends RuntimeException {
         public StemmachineException(){
              super();
         public StemmachineException(String s){
              super(s);
    code:
    Thank you guys

    does the class have a package 'verkiezingen'? I don't see the package statement in your source listing.
    For that matter, is the class in a subdirectory 'verkiezingen' inside the jar?
    btw 1: use code tags when posting code to prevent the forum from swallowing certain characters, and to make it far more readable
    btw 2: boooooo to non-English class names :( I hope you don't get coworkers that don't speak Dutch.

  • Problems creating packaged .h files with javah -jni

    I have all of my .java and .class files in package ClassLib.Satrack.
    My directory structure is C:/SatrackIIP/NavComponent/ClassLib/Satrack.
    I compiled all java files by calling javac ClassLib/Satrack/*.java from NavComponent directory. Then still from NavComponent directory, I call javah -jni ClassLib/Satrack/TrajectoryGenerator. However I am getting an error message:
    Error: Class ClassLib/Satrack/TrajectoryGenerator could not be found.
    Why am I getting this error?

    Fixed it. I should be calling javah -jni ClassLib.Satrack.TrajectoryGenerator and not using dashes in between.

  • I am having problems creating PDF file and downloading them

    I am having problems creating PDF file and downloading them

    Hi Randy Keil,
    You might need to sign up with your Adobe ID and password at "https://cloud.acrobat.com/convertpdf"
    Then you can choose the desired files to create the PDF.
    Now, let me know what error message do you get while doing the same.
    What kind of files are you trying to convert to PDF?
    Have you checked with your internet connection and tried using a different browser?
    Hope to get your response.
    Regards,
    Anubha

  • Problem with zipping file with chinese chars

    I need to zip a html page which contains some chinese characters, I am able to zip it and create a zip file
    but the problem is when i open the zip file and view the html file it displays junk characters instead
    of chinese characters
    Here is what i am doing
      ByteArrayOutputStream bStream = new ByteArrayOutputStream();
       ZipOutputStream zStream = new ZipOutputStream(bStream);
        ZipEntry zipEntry = new ZipEntry(htmlFilename);
        zStream.putNextEntry(zipEntry);
        ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
        PrintWriter writer = new PrintWriter(
                               new OutputStreamWriter(dataStream,"UTF-8"));
    writer.write(htmlString); //htmlString is the string which contents the html contents which has chinese char
        writer.close();
    zStream.write(dataStream..toByteArray());

    And when you view the unzipped file, are you using something that realizes that you encoded your data using UTF-8? My guess is that you are not.
    PC²

  • Hello i am rajesh i am having problem while conveting other files into pdf format please help me

    i am rajesh i am having problem while converting other files into acrobat format please help me

    Hello Rajesh,
    I'm sorry to hear you're having trouble. Are you using Acrobat.com to convert your files to PDF? Please let me know where you are having trouble and I will do my best to help you convert your files. For your reference, here is a list of filetypes that can be converted to PDF online with Acrobat.com:
    http://kb2.adobe.com/cps/524/cpsid_52456.html#Create%20PDF
    Best,
    Rebecca

  • Zip.ZipInputStream cannot extract files with Chinese chars in name

    Dear friends,
    Peace b upon u!
    I am trying to read a zip file (~3000 files)containing one
    or more files with Chinese, Japanese or Korean names, the
    getNextEntry method throws an IllegalArgumentException as below after extracting just ~300 files as below:-
    java.lang.IllegalArgumentException
            at java.util.zip.ZipInputStream.getUTF8String(Unknown Source)
            at java.util.zip.ZipInputStream.readLOC(Unknown Source)
            at java.util.zip.ZipInputStream.getNextEntry(Unknown Source)
            at testZipFiles.getZipFiles(testZipFiles.java:65)
            at testZipFiles.main(testZipFiles.java:18) issue:java.util.zip.ZipInputStream cannot extract files with Chinese chars in name
    Category java:classes_util_jarzip
    Plz let me know 1 of the ways which I can solve this issue.
    1)if someone has JAVA DCOMPILER plz send the SOURCE Code
    for the ZipInputStream.class to me..I need to edit it using 1 of the solutions as provided below which I googled.
    2)If there is an alternate or upgraded java.util.zip.ZipInputStream or any org.apache.tools.zip.* package which can read such files..If yes where I can download the same on net.
    3)Any other easier solution, which can let me extract all files (by excluding Chinese files thru CATCH) without the extractor process to fail altogether.
    On net I found that the only solution with this is:-
    - edit the new ZipEntry, remove the static initializer that calls
    the native methods initIDs().
    this step seems a bit scary, but it's according to the
    workaround
    to bug #4244499 (the workaround of Olive64, THU JUN 05
    01:55 P.M. 2003),
    that handles a similar bug at the ZipOutputStream.
    Now you have a ZipInputStream that supports multi-bytes
    entry names.
    to extract the zip file, using the fixed code that is offered
    above,
    create a function that gets an "encoding" string, a "destPath"
    string
    and a "sourceFile" (zipped) and does :
    ZipInputStream zipinputstream = null;
    ZipEntry zipentry;
    zipinputstream = new ZipInputStream(new FileInputStream
    (sourceFile),encoding);
    zipentry = zipinputstream.getNextEntry();
    while (zipentry != null) { //for each entry to be extracted
        String entryName = zipentry.getName();
        int n;
        FileOutputStream fileoutputstream = new FileOutputStream
    ( destPath + entryName );
        while ((n = zipinputstream.read(buf, 0, 1024)) > -1)
            fileoutputstream.write(buf, 0, n);
        fileoutputstream.close();
        zipinputstream.closeEntry();
        zipentry = zipinputstream.getNextEntry();
    }//while
    zipinputstream.close();

    Hi friend,
    We'd better to ask one question in each thread. If you have another issue, you can consider to open up a new thread in this forum.
    Now for the first question, do you mean this picture? It throws access exception in archive2.
    If so , because your extractPath is a path, not a directory.You should add +"xxx.zip". For more information, please refer to
    ZipFile.Open
    Method (String, ZipArchiveMode).
    For the second question, you can use the following code to skip the error message.
    while (true)
    try
    //do something;
    catch (Exception ex)
    { continue; }
    Good day!
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Create a zip files in a special way

    Dear all,
    Following my yesterday's posting, I would clarify my questions:
    I successfully created a zip file which contains a folder structure and two files from strings. See attached codes.
    However, I don't like the way that I physically created subfolder and files before add them to the zip file.
    Is there any possibility to avoid that part of creating multiple folders?
    Regards.
    Pengyou
    package com.zip.test;
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    public class ZipTest {
         static final int BUFFER = 2048;
         public static void main(String argv[]) {
              try {
                   BufferedInputStream origin = null;
                   FileOutputStream dest = new FileOutputStream("mytest.zip");
                   ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(
                             dest));
                   // out.setMethod(ZipOutputStream.DEFLATED);
                   byte data[] = new byte[BUFFER];
                   try {
                        String strManyDirectories = "root/dir1/dir2";
                        // Create multiple directories
                        boolean success = (new File(strManyDirectories)).mkdirs();
                        if (success) {
                             System.out.println("Directories: " + strManyDirectories
                                       + " created");
                        File outputFile = new File("root/dir1/dir2/test.html");
                        BufferedWriter bufferedWriter = new BufferedWriter(
                                  new FileWriter(outputFile));
                        bufferedWriter.write("Hello, Test");
                        bufferedWriter.close();
                        File outputFile1 = new File("root/dir1/dir2/test1.html");
                        BufferedWriter bufferedWriter1 = new BufferedWriter(
                                  new FileWriter(outputFile1));
                        bufferedWriter1.write("Hello, Test1");
                        bufferedWriter1.close();
                   } catch (IOException e) {
                   String files[] = { "root/dir1/dir2/test.html",
                             "root/dir1/dir2/test1.html" };
                   for (int i = 0; i < files.length; i++) {
                        System.out.println("Adding: " + files);
                        FileInputStream fi = new FileInputStream(files[i]);
                        origin = new BufferedInputStream(fi, BUFFER);
                        ZipEntry entry = new ZipEntry(files[i]);
                        out.putNextEntry(entry);
                        int count;
                        while ((count = origin.read(data, 0, BUFFER)) != -1) {
                             out.write(data, 0, count);
                        origin.close();
                   out.close();
              } catch (Exception e) {
                   e.printStackTrace();

    pengyou wrote:
    But I did not understand how to convert a String to ZipOutputStream with a user choosen file name and a user choosen folder structure.
    I am blocked at that point. Sorry for repeating the same question.
    That doesn't make sense to me. Even more so as your sample code suggests that you are familiar with Writer and ZipEntry concepts. Can you explain in detail where you are stuck or what part of my previous suggestion was unclear to you?
    Scratch that, I think I finally understand your problem. I think the following sample code will get you on track:import java.util.zip.ZipOutputStream;
    import java.util.zip.ZipEntry;
    import java.io.FileOutputStream;
    import java.io.BufferedWriter;
    import java.io.OutputStreamWriter;
    public class ZipTest {
        public static void main( String[] args ) throws Exception {
            final String[] content = {"bla", "blubber"};
            final String[] names = {"root/content1/c1.txt", "root/content2/c2.txt"};
            final String path = System.getProperty("user.home") + "/test.zip";
            ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(path));
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(zos, "UTF-8"));
            for (int i = 0; i < content.length; ++i) {
                final ZipEntry entry = new ZipEntry(names);
    zos.putNextEntry(entry);
    bw.write(content[i]);
    bw.flush();
    zos.closeEntry();
    // this will close zos, too
    bw.close();
    Edited by: thomas.behr on Apr 22, 2009 4:10 PM

  • Problem while exporting to PDF with japanese character in Crystal Report X1

    Hi,
    I am using Crystal report X1 with classic ASP on a Windows 2003 Enterprise Server, SP 2. In my application, I have to export the report into PDF, CSV, DOC formats. I am have Japanese strings in the report. While exporting to PDF, empty boxes has displayed in the place of Japanese string and in CSV file, question mark has been displayed instead of Japanese string. But the Doc file is exported correctly. I have not installed any language support software either in server or in client machine. I have used MS Gothic and Arial Unicode MS fonts for the text-objects which has Japanese strings.
    Please give me a solution so that I will get PDF file with Japanese strings instead of empty box or question mark.
    Do I need to install any language support pack software?
    Thanks in advance.
    Regards,
    Manju

    Hi Don,
    Thank You for your reply. I have resolved the issue of exporting to pdf from crystal report X1 having Japanese data after installing the language pack.
    But when I am exporting to CSV or TXT, i am getting ??? instead of Japanese characters. I have tried "export" through crystal report designer and got ??? instead of Japanese.
    The Crystal report version I am using is Crystal report X1  11.0.0.1282
    Crystal Report Desinger is installed in Windows Xp machine
    Font set for Text object is Arial Unicode MS, MS PMincho, MS PGothic
    Does the Crystal report X1 11.0.0.1282 has the UTF-8 support for CVS / txt
    Please provide me a solution
    Thanks in advance,
    Regards,
    Manju

  • Create a flat file with multiple characters for enclosures

    Hello,
    we use OWB 11g2 (11.2.02).
    Now we try to create a flat file with multiple characters for enclosures. The manual wrote:
    "Enclosures (Left and Right): Some delimited files contain enclosures that denote text strings within a field. If the file contains enclosures, enter an enclosure character in the text box or select one from the list. The list displays commonenclosures. However, you may enter any character. The default for both the left and right enclosure is the double quotation mark ("). You can specify multiple characters and hexadecimal characters as field enclosures."
    But it will not work. The OWB use the first character from the left enclosure definition as left enclosure and the second one as right enclosure !?!
    Did anyone know this behavior? Is there a solution for this problem?
    Thanks and regards
    Norbert

    HI Raghu,
               Use the function module 'GUI_UPLOAD'.
               In that you have to specify the field_separator value = 'X' in export section.
    Regards,
    S.C.K

Maybe you are looking for

  • Internal Server Error while deploying a project to a remote BPEL instance.

    Some background. We were trying to use the adapters going out through iWay to hit a Siebel instance. Originally, we were using a BPEL VM for development, and trying to hit adapters on the iWay box. We found out that we needed to have BPEL and adapter

  • Cost of iPhone 5

    what will be the price of iPhone 5 16 GB witout contract in India after the public release of iPhone 5s and iPhone 5c??

  • InputDate and Data parameter from query

    Hello, I'm expiriencing some problems with my Web project, I have Model and View. I created ViewObject from query with parameter: SELECT  r.room_id FROM rooms r WHERE (r.from_date>=:from_date);Parameter :from_date has type 'Date'. In ApplicationModul

  • JSF selectOneChoice  VS.  Swing JComboBox

    I have been so impressed with how clean it is using a JSF selectOneChoice with a selectItem and selectItems. Using selectItem.itemValue and selectItem.itemLabel is intuitive, and fills a very common need. I'm wondering if there is a similar type of c

  • DVCPRO HD footage problems with Quicktime 10 and MacBook Pro

    I am trying to open DVCPRO HD footage in Quicktime 10 on my computer and just get black screen with no video. Cannot get these files to play yet can get other ones to play, just not the DVCPRO HD footage shot with Panasonic P2 cards. I can play the s