Java Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Java Examples

Quick Start
Java Unicode
Java Certs
Java Email
Java Encryption
Java FTP
HTML-to-XML
Java HTTP
Java IMAP
Java MHT
Java MIME
Java RSA
Java S/MIME
Java Signatures
Java Socket
Java Spider
Java Tar
Java Upload
Java XML
Java XMP
Java Zip

More Examples...
Email Object
POP3
SMTP
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
Bzip2
LZW
Bz2
Icon

 

 

 

 

 

 

 

Zip with Unicode Filenames

The NTFS filesystem supports Unicode and filenames can contain characters in any language. However, the Zip file standard is only capable of supporting a single language at a time (i.e. a single OEM code page). If your computer's default OEM code page is different than the language of the filename, then you would need to set the Zip.OemCodePage property to the correct value prior to appending files.

Here is a list of OEM code pages:
437 OEM - United States
737 OEM - Greek (formerly 437G)
775 OEM - Baltic
850 OEM - Multilingual Latin I
852 OEM - Latin II
855 OEM - Cyrillic (primarily Russian)
857 OEM - Turkish
858 OEM - Multlingual Latin I + Euro symbol
860 OEM - Portuguese
861 OEM - Icelandic
862 OEM - Hebrew
863 OEM - Canadian - French
864 OEM - Arabic
865 OEM - Nordic
866 OEM - Russian
869 OEM - Modern Greek
874 ANSI/OEM - Thai (same as 28605, ISO 8859-15)
932 ANSI/OEM - Japanese, Shift-JIS
936 ANSI/OEM - Simplified Chinese (PRC, Singapore)
949 ANSI/OEM - Korean (Unified Hangeul Code)
950 ANSI/OEM - Traditional Chinese (Taiwan; Hong Kong SAR, PRC)

Download Chilkat Java Library

import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {

    //  This example creates a .zip with filenames containing
    //  Chinese characters.  Using Chilkat Zip, the .zip can
    //  be created and unzipped on any locale computer.  However,
    //  to unzip using a program such as WinZip, it must run
    //  on a computer with the correct locale.

    CkZip zip = new CkZip();

    boolean success;

    //  Any string unlocks the component for the 1st 30-days.
    success = zip.UnlockComponent("Anything for 30-day trial");
    if (success != true) {
        System.out.println(zip.lastErrorText());
        return;
    }

    zip.NewZip("chinese.zip");

    //  Set the OEM code page to Chinese Big5
    zip.put_OemCodePage(950);

    //  Add references to all files under a "chinese" subdirectory.
    //  This directory will contain filenames having Chinese characters.
    zip.AppendFiles("chinese",true);

    success = zip.WriteZipAndClose();
    if (success != true) {
        System.out.println(zip.lastErrorText());
        return;
    }

    //  Create a new instance of a zip object.  Load the .zip
    //  we previously created and unzip to another directory.
    CkZip zip2 = new CkZip();

    //  Don't forget to set the OEM code page...
    zip2.put_OemCodePage(950);

    success = zip2.OpenZip("chinese.zip");
    if (success != true) {
        System.out.println(zip2.lastErrorText());
        return;
    }

    //  This will unzip correctly on any locale computer.
    success = zip2.Unzip("outDir");
    if (success != true) {
        System.out.println(zip2.lastErrorText());
    }
    else {
        System.out.println("unzipped!");
    }


  }
}

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.