A Problem about zip a Chinese File with Java Zip package

Hi,
my problem is following:
I use "Java(1.3.1_02) Zip package" to compress some files into a zip File
all thing is smooth except one:(
If there is a fileName with Chinese (big5 encoding) characters
it doesen't work!
Can anyone tell me how to do?
Thanks a lot!

Hi !
i do have a problem relating with the different character(korean).Hope u must be working with chinese characters.My problem is while displaying the korean characters from database , the characters are broken and not able to display on jsp pages.....
Hope u can understand my problem.....
Thanks....

Similar Messages

  • Problem about Handling of Empty Files in File Adapter

    Hello everyone,
    NetWeaver 2004s --- XI
    In Sender i have a File Adapter.
    Now i meet a problem about Handling of Empty Files. When i send empty file, but don't cerate a leer message.
    I have seen following text in help document. But in adapter configuration i can not find the correspond parameter.
    can you give me some tips?
    Thx in advance
    best regards
    Yaning
    SAP Help Document über File Adapter
    +Handling of Empty Files
    Specify how empty files (length 0 bytes) are to be handled.
    ○       Do Not Create Message
    No XI messages are created from empty files.
    The files are processed according to the selected Processing Mode.
    For example, if the processing mode is Delete, empty files are deleted in the source directory.
    ○       Process Empty Files
    XI messages are created with an empty main payload.
    The files are processed according to the selected Processing Mode.
    ○       Skip Empty Files
    No XI messages are created from empty files.
    Empty files are skipped and remain in the source directory.+
    Help Docu

    hi,
    it's available since Sp19 for XI 3.0
    and the corresponding SPS fpr XI 7.0
    http://help.sap.com/saphelp_nw04/helpdata/en/44/f565854b7341e6e10000000a1553f6/frameset.htm
    so probably you need to install the new SP
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • Problem unzipping larger files with Java

    When I extract small zip files with java it works fine. If I extract large zip files I get errors. Can anyone help me out please?
    import java.io.*;
    import java.util.*;
    import java.net.*;
    import java.util.zip.*;
    public class  updategrabtest
         public static String filename = "";
         //public static String filesave = "";
        public static boolean DLtest = false, DBtest = false;
         // update
         public static void main(String[] args)
              System.out.println("Downloading small zip");
              download("small.zip"); // a few k
              System.out.println("Extracting small zip");
              extract("small.zip");
              System.out.println("Downloading large zip");
              download("large.zip"); // 1 meg
              System.out.println("Extracting large zip");
              extract("large.zip");
              System.out.println("Finished.");
              // update database
              boolean maindb = false; //database wasnt updated
         // download
         public static void download (String filesave)
              try
                   java.io.BufferedInputStream in = new java.io.BufferedInputStream(new
                   java.net.URL("http://saveourmacs.com/update/" + filesave).openStream());
                   java.io.FileOutputStream fos = new java.io.FileOutputStream(filesave);
                   java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
                   byte data[] = new byte[1024];
                   while(in.read(data,0,1024)>=0)
                        bout.write(data);
                   bout.close();
                   in.close();
              catch (Exception e)
                   System.out.println ("Error writing to file");
                   //System.exit(-1);
         // extract
         public static void extract(String filez)
              filename = filez;
            try
                updategrab list = new updategrab( );
                list.getZipFiles();
            catch (Exception e)
                e.printStackTrace();
         // extract (part 2)
        public static void getZipFiles()
            try
                //String destinationname = ".\\temp\\";
                String destinationname = ".\\";
                byte[] buf = new byte[1024]; //1k
                ZipInputStream zipinputstream = null;
                ZipEntry zipentry;
                zipinputstream = new ZipInputStream(
                    new FileInputStream(filename));
                zipentry = zipinputstream.getNextEntry();
                   while (zipentry != null)
                    //for each entry to be extracted
                    String entryName = zipentry.getName();
                    System.out.println("entryname "+entryName);
                    int n;
                    FileOutputStream fileoutputstream;
                    File newFile = new File(entryName);
                    String directory = newFile.getParent();
                    if(directory == null)
                        if(newFile.isDirectory())
                            break;
                    fileoutputstream = new FileOutputStream(
                       destinationname+entryName);            
                    while ((n = zipinputstream.read(buf, 0, 1024)) > -1)
                        fileoutputstream.write(buf, 0, n);
                    fileoutputstream.close();
                    zipinputstream.closeEntry();
                    zipentry = zipinputstream.getNextEntry();
                }//while
                zipinputstream.close();
            catch (Exception e)
                e.printStackTrace();
    }

    In addition to the other advice, also change every instance of..
    kingryanj wrote:
              catch (Exception e)
                   System.out.println ("Error writing to file");
                   //System.exit(-1);
    ..to..
    catch (Exception e)
    e.printStackTrace();
    }I am a big fan of the stacktrace.

  • Can't create log file with java.util.logging

    Hi,
    I have created a class to create a log file with java.util.logging
    This class works correctly as standalone (without jdev/weblogic)
    import java.io.IOException;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.logging.*;
    public class LogDemo
         private static final Logger logger = Logger.getLogger( "Logging" );
         public static void main( String[] args ) throws IOException
             Date date = new Date();
             DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
             String dateStr = dateFormat.format(date);
             String logFileName = dateStr + "SEC" + ".log";
             Handler fh;          
             try
               fh = new FileHandler(logFileName);
               //fh.setFormatter(new XMLFormatter());
               fh.setFormatter(new SimpleFormatter());
               logger.addHandler(fh);
               logger.setLevel(Level.ALL);
               logger.log(Level.INFO, "Initialization log");
               // force a bug
               ((Object)null).toString();
             catch (IOException e)
                  logger.log( Level.WARNING, e.getMessage(), e );
             catch (Exception e)
                  logger.log( Level.WARNING, "Exception", e);
    }But when I use this class...
    import java.io.File;
    import java.io.IOException;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.logging.FileHandler;
    import java.util.logging.Handler;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import java.util.logging.XMLFormatter;
    public class TraceUtils
      public static Logger logger = Logger.getLogger("log");
      public static void initLogger(String ApplicationName) {
        Date date = new Date();
        DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
        String dateStr = dateFormat.format(date);
        String logFileName = dateStr + ApplicationName + ".log";
        Handler fh;
        try
          fh = new FileHandler(logFileName);
          fh.setFormatter(new XMLFormatter());
          logger.addHandler(fh);
          logger.setLevel(Level.ALL);
          logger.log(Level.INFO, "Initialization log");
        catch (IOException e)
          System.out.println(e.getMessage());
    }and I call it in a backingBean, I have the message in console but the log file is not created.
    TraceUtils.initLogger("SEC");why?
    Thanks for your help.

    I have uncommented this line in logging.properties and it works.
    # To also add the FileHandler, use the following line instead.
    handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandlerBut I have another problem:
    jdev ignore the parameters of the FileHandler method .
    And it creates a general log file with anothers log files created each time I call the method logp.
    So I play with these parameters
    fh = new FileHandler(logFileName,true);
    fh = new FileHandler(logFileName,0,1,true);
    fh = new FileHandler(logFileName,10000000,1,true);without succes.
    I want only one log file, how to do that?

  • I can't open or save file with Java Web Start

    Hi,
    i can't open or save file with Java Web Start:
    import java.io.*;
    import java.util.*;
    public class MetaDataFileCreator {
    public String fileNameSpace = null;
    public String fileName = null;
    protected Properties file = null;
    public MetaDataFileCreator(String fileNameSpace, String fileName) {
    this.fileNameSpace = fileNameSpace;
    this.fileName = fileName;
    public void createMetaDataFile() {
    try {
    System.out.println("file METADATA");
    ClassLoader cl = this.getClass().getClassLoader();
    String nameFileMetaData = fileNameSpace + fileName + ".txt";
    FileOutputStream fileOS = new FileOutputStream(cl.getResource(nameFileMetaData).getFile());
    file = new Properties();
    file.setProperty("aaaaa", "aaaa");
    file.store(fileOS, "");
    fileOS.close();
    } catch (Exception e) {
    System.out.println("Error writing metadata-file: " + e);
    System.exit(1);
    e.printStackTrace();
    I have try also to open a file like this:
    ClassLoader cl = this.getClass().getClassLoader();
    file.load(cl.getResourceAsStream(nameFile));
    also like this:
    try {
    fos = (FileOpenService)ServiceManager.lookup("javax.jnlp.FileOpenService");
    fss = (FileSaveService)ServiceManager.lookup("javax.jnlp.FileSaveService");
    } catch (UnavailableServiceException e) {
    fss = null;
    fos = null;
    System.out.println("Error with JNLP");
    System.exit(1);
    if (fss != null && fos != null) {
    try {
    // get a FileContents object to work with from the
    // FileOpenService
    FileContents fc = fos.openFileDialog(null, null);
    //FileContents newfc2 = fss.saveAsFileDialog(null, null, fc);
    // get the OutputStream and write the file back out
    if (fc.canWrite()) {
    // don't append
    os = fc.getOutputStream(false);
    } catch (Exception e) {
    e.printStackTrace();
    also like this:
    File f = new File((System.getProperty("user.home")+"x.txt").toString());
    FileOutputStream fileX = new FileOutputStream(f);
    OutputX = new PrintWriter(new BufferedWriter(new OutputStreamWriter(fileX, "UTF8")));
    OutputX.println(....
    but it doesn't work with Java Web Start.
    Can someone help me?
    How can I open or save file?
    thank you.
    Sebastiano

    Did you specify <all-permissions/> in your JNLP file? Did you sign your code? What error are you getting?

  • How to use parameter file with java

    Is it possible to use a parameter file with Java, and is there any class/method to make it easy to call and use these parameter from a text file, other than scanning the whole text file manually as we can do normally with visual basic/c++, so we can call the program with the parameter file, like java testing c:\\testing.ini

    If I understand you correctly, you may be looking for a properties file. This is basically a text file that contains pairs of strings in the form:
    parameter1=value1
    parameter2=value2
    parameter3=value3
    ...etc.
    and the values are retrieved using the java.util.Properties class - see:
    http://java.sun.com/j2se/1.3/docs/api/java/util/Properties.html
    Sample use://Call chis method once, to load the props file.
    //props file is called "demo.properties", and is
    //in a directory that is included in the classpath
        private void loadMyProperties() throws Exception
         InputStream stream = getResourceAsStream("/demo.properties");
         if(stream == null)
             throw new Exception("stream is null!");
         demoProperties = new Properties();
         demoProperties.load(stream);
         stream.close();
    // Then you can retrieve properties in your code using:
    String param3 = demoProperties.getProperty("parameter3");
    //...etc

  • Executing a file with Java?

    Hi,
    I wanted to know how I could execute a file with java. Here are a couple scenarios - let's say I am developing an anti-spyware utility and I wanted to first write a batch file, and then create it in a folder, then run it when they click "Run". Then afterwards I want to shutdown their computer.
    My Mindset:
    - FileWriter to create the .bat and write the Batch commands.
    - Execute the batch file.
    - Execute the shutdown.exe file to reboot their PC.
    So my simple question is, how can I execute a file?
    Thanks!
    -Josh

    Well here is the code I have:
                try
                    Runtime.getRuntime().exec("cmd.exe /c test.bat");
                catch(IOException e1)
                    //NOTHING
                }Now my cmd.exe is obviously in my Windows System32 folder, and my "test.bat" file is in my C:\ root directory. So I am wondering why that wont execute. I tried a fer other things too like:
    Runtime.getRuntime().exec("cmd.exe  c:\test.bat");that didn't work either, because you can't have a "\" in a string...
    So how can I get this thing to execute the batch file?

  • Is it possible to play .rm and .wma file with java?

    Hello Friends,
    Please tell me,
    how to play .rm and .wma file with java?
    Thanks,
    Harsh Modha

    As far as I know, you can not play those files.
    Here you have the complete list of supported formats. Hope this helps.
    http://java.sun.com/products/java-media/jmf/2.1.1/formats.html
    Maybe you should try to convert from wma or rm to a supported format before attempting to play it.

  • How to ZIP a PDF File with a Password Protection

    Hi,
    i've a pdf file with created smartforms and i want to assign a password to that pdf file but the SAP doesn't let doing that protection. So i want to create a zip file with a password protection for PDF file.
    How can i create a zip file with a password protection? Can somebody help me please?
    Thanks.

    Hello,
    Check this links
    Take a look to the class CL_ABAP_GZIP
    open (top-)zip-archive
    CALL METHOD lo_zip->load
        EXPORTING
          zip             = lv_zip_file_head
        EXCEPTIONS
          zip_parse_error = 1
          OTHERS          = 2.
    create sub-zip-archives which contain the files you would assign to a folder
    add sub-zip-archive to top-zip-archive
    CALL METHOD lo_zip->add
         EXPORTING
            name    = lv_zip_filename
            content = lv_zip_file.
    save zip-archive
    CALL METHOD lo_zip->save
        RECEIVING
          zip = ev_zip_file.
    ABAP Development
    How to ZIP a PDF file email attachment
    Re: How to ZIP a PDF file email attachment

  • Extracting file from a TAR file with java.util.zip.* classes

    Is there a way to extract files from a .TAR file using the java.util.zip.* classes?
    I tried in some ways but I get the following error:
    java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.<init>(ZipFile.java127)
    at java.util.zip.ZipFile.<init>(ZipFile.java92)
    Thank you
    Giuseppe

    download the tar.jar from the above link and use the sample program below
    import com.ice.tar.*;
    import java.util.zip.GZIPInputStream;
    import java.io.*;
    public class untarFiles
         public static void main(String args[]){
              try{
              untar("c:/split/20040826172459.tar.gz",new File("c:/split/"));
              }catch(Exception e){
                   e.printStackTrace();
                   System.out.println(e.getMessage());
         private static void untar(String tarFileName, File dest)throws IOException{
              //assuming the file you pass in is not a dir
              dest.mkdir();     
              //create tar input stream from a .tar.gz file
              TarInputStream tin = new TarInputStream( new GZIPInputStream( new FileInputStream(new File(tarFileName))));
              //get the first entry in the archive
              TarEntry tarEntry = tin.getNextEntry();
              while (tarEntry != null){//create a file with the same name as the tarEntry  
                   File destPath = new File(
                   dest.toString() + File.separatorChar + tarEntry.getName());
                   if(tarEntry.isDirectory()){   
                        destPath.mkdir();
                   }else {          
                        FileOutputStream fout = new FileOutputStream(destPath);
                        tin.copyEntryContents(fout);
                        fout.close();
                   tarEntry = tin.getNextEntry();
              tin.close();
    }

  • Problem in loading an external file with unicode name

    Hi,
    I am working on a project which involves loading of an
    external file with unicode name for ex:
    "插入音乐.mp3
    ,插入音乐.jpg". These unicode files are
    loaded successfully when I play/publish the movie with flash player
    alone.
    But when the movie is embedded in to HTML file, it is failing
    to load files with unicode name. this works fine with English name.
    is it a bug? if not pls help.. on this issue
    Thx

    what is your code? so we can get clear picture.

  • How to zip a whole catalog with Java?

    can you tell me how to zip a whole catalog?
    i am not able to find a method that can zip a whole catalog and the files in it.
    please help me,thanks

    The following program is an extension of the code posted at:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=48084
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream ;
    import java.util.zip.CRC32;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    import java.util.Date;
    public class NZipCompresser {
       private String m_basePath=null;
       private File m_dir = null;
       private String m_OutputFileName;
       public static void main(String[] args) {
          File directory=new File(args[0]);
          new NZipCompresser(directory, args[1]);
       public NZipCompresser() {
       // This class gets directory and compress it reqursivelyinto zip file named outputFileName
       public NZipCompresser(File directory,String outputFileName) {
          m_dir = directory;
          m_OutputFileName = outputFileName;
          try {
             compress();
          } catch (Throwable e) {}
       public void compress () throws Exception {
          try {
             FileOutputStream zipFilename = new FileOutputStream(m_OutputFileName) ;
             ZipOutputStream zipoutputstream = new ZipOutputStream (zipFilename);
             m_basePath = m_dir.getPath();
             CompressDir (m_dir,zipoutputstream);
             zipoutputstream.setMethod(ZipOutputStream.DEFLATED);
             zipoutputstream.close();
          catch (Exception e) {
             throw new Exception ("Something wrong in compresser: " + e);
       public void setDirectory (File dir) {
          m_dir = dir;
       public void setOutputFileName (String FileName) {
          m_OutputFileName = FileName;
       public File getDirectory () {
          return m_dir;
       public String getOutputFileName () {
          return m_OutputFileName;
       //Walker through directory structure
       private void CompressDir (File f, ZipOutputStream zipoutputstream) {
          System.out.println(f);
          if (f.isDirectory()) {
             File [] files = f.listFiles();
             for (int j=0;j<files.length;j++) {
                if (files[j].isDirectory()) {
                   System.out.println("calling CompressOneDir with:"+files[j].getPath());
                   CompressDir (files[j],zipoutputstream);
                if (files[j].isFile()) {
                   System.out.println("adding file:" +  files[j].getPath());
                   addOneFile(files[j],zipoutputstream);
          System.out.println("exiting:"+f);
       //Actualy compress the file
       private void addOneFile (File file, ZipOutputStream zipoutputstream) {
          ZipEntry zipentry = new ZipEntry(file.getPath().substring(m_basePath.length()+1));
          FileInputStream fileinputstream;
          CRC32 crc32 = new CRC32();
          byte [] rgb = new byte [1024];
          int n;
          //Compute CRC of input stream
          try {
             fileinputstream = new FileInputStream(file);
             while ((n = fileinputstream.read(rgb)) > -1) {
                crc32.update(rgb, 0, n);
             fileinputstream.close();
          catch (Exception e) {
             System.out.println("Error in computing CRC:");
             e.printStackTrace();
          //Set Up Zip Entry
          zipentry.setSize(file.length());
          zipentry.setTime(file.lastModified());
          zipentry.setCrc(crc32.getValue());
          //Write Data
          try {
             zipoutputstream.putNextEntry(zipentry);
             fileinputstream = new FileInputStream(file);
             while ((n = fileinputstream.read(rgb)) > -1) {
                zipoutputstream.write(rgb, 0, n);
             fileinputstream.close();
             zipoutputstream.closeEntry();
          catch (Exception ex) {
             System.out.println("Error in writing data:");
             ex.printStackTrace();
    }Compile this program and run it as follows:
    java NZipCompresser directory_name zipOutput_name
    Is this what you're looking for?
    V.V.

  • [b]The challenge is on: Creating PowerPoint Files with Java[/b]

    Hi, guys and geeks!!
    I'm new here and generally not as skilled and talented as you guys -
    that's why I am passing this challenge on to you:
    I want to create a PowerPoint presentation using Java. (My Data will be in XML and I'll have to generate slides with Flow-Charts from that data)
    1.
    I know of only one commercial Library that seems to do this very comfortably. But it costs about $5000... (http://tonicsystems.com/) - have you used it?
    2.
    I know that I could use Apache's POI (http://jakarta.apache.org/poi/), as it gives me access to the MsOLE 2 compound doc. format, but their work is most developed only for Excel and Word. so I'm not sure what kind of obstracles I'd be facing....
    3.
    And then there is JAWIN (http://jawinproject.sourceforge.net/) which would enable me to call COM-Components... How would I do that?
    Any other /better ideas?
    So, please let me know your thoughts and if you know what I could do!
    Also, please let me know how I should go about with it.....
    I'm looking forward to seeing your "muscles" (i.e. knowledge) play...!
    Cheers,
    Anna ;o)

    Hi i'm still working on my program to generate PowerPoint Files with Jawin. I'm trying to get the heght property on a row.
    For example: rows(1).height
    I can get rows. but not rows(1).
    I got a jawin Exception on :
    public int getRowHeight(int row) throws COMException
    DispatchPtr rows;
    int rowHeight;
    DispatchPtr theRows = (DispatchPtr) this.getDispatchPtr().get("Rows",new Integer(1));
    rowHeight = (Integer) theRows.get("Height");
    return rowHeight;
    Here is the stacktrace:
    org.jawin.COMException: 80020003: Member not found.
    at org.jawin.marshal.GenericStub.dispatchInvoke0(Native Method)
    at org.jawin.marshal.GenericStub.dispatchInvoke(GenericStub.java:201)
    at org.jawin.DispatchPtr.getN(DispatchPtr.java:248)
    at org.jawin.DispatchPtr.get(DispatchPtr.java:194)
    at pptpublisher.PPTTable.getRowHeight(PPTTable.java:117)
    at pptpublisher.Main.main(Main.java:51)
    Thanks for replying

  • I would like to zip two .Txt files in java

    hi all,
    i would like to zip two temporaray files(.Txt) in java

    Do you want to write a part of it yourself or do you want us to prepare you a complete solution? I provided you with a link to Java's zipping tutorial. If you took the effort to read it, you'll know there is an example zip.java.
    You can put the initialisation in your main, take what's in the for loop, put it into a function. I assume you can write a program that takes 2 command line parameters, and pass those params to your zip function and you've got it... That's how far I'll go for your solution!

  • How to read and parse a remote XML file with Java

    Hi.
    Using J2SE v1.4.2, I'd like to read and parse a remote file:
    http://foo.com/file.xml
    Is it possible with Java? I'd be extremely grateful if someone could provide me any webpage showing a very simple code.
    Thank you very much.

    How about the following?
         import java.io.InputStream;
         import java.net.URL;
         import javax.xml.parsers.DocumentBuilder;
         import javax.xml.parsers.DocumentBuilderFactory;
         import org.w3c.dom.Document;
         public static void main(String[] args) throws Exception {
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              DocumentBuilder db = dbf.newDocumentBuilder();
              URL url = new URL("http://foo.com/file.xml");
              InputStream inputStream = url.openStream();
              Document document = db.parse(inputStream);
              inputStream.close();
         }-Blaise

Maybe you are looking for

  • Audio and video out of sync on iPod

    The videos I have imported to watch on my iPod appear to play well with one major exception. The audio and video are badly out of sync. I have yet to find a solution to the problem. Can someone please help me?

  • My Daughters Ipod is locked and says it can be unlock in 22 million minutes

    Her Ipod died and when it was charged up and we turned it back on it said unable to unlock try again in 22,785,238 minutes. We have no idea how this happened. Any help would be much appreciated, Thank You

  • Convert Purchase Order to Requisition when contract void

    Hi We are using SRM 5.0, R/3 Backend is 4.6C. For purchase orders for items with contracts that are expired or for incoming requests exceeding target quantity in the contract, we intend to have the purchase order converted to a purchase requisistion

  • Nokia X2 - Incoming MMS is too small ( 2,8 kb ) !

    i tried everything. New SIM card, i did update 2 times phone software. I did send from 3 different phones pictures and incoming to my phone is still the same. Size between 2 and 4 kb. Its so small that its even not possible to see whats on picture. M

  • Html to browser in servlets

    When JSP's are compiled as servlets, does the servlet send HTML to the browser during the html generation or does it send after the complete html is generated?           Thanks           AJ