Creating zip files in pl/sql.

I'm using code posted on this forum to create zip file in pl/sql. Works greate for combing multiple files into one archive. That's until I have to add a zip file.
Here's my test:
drop table t1;
create table t1 (file_name varchar2(100), file_blob blob);
declare
v_new_blob blob;
v_file_name varchar2(100);
v_buffer_raw raw(1000);
v_length integer;
b_zipped_blob BLOB;
zip_files zz_zip.file_list;
t_file blob;
begin
     dbms_lob.createtemporary(v_new_blob,true);
     v_buffer_raw := UTL_RAW.cast_to_raw('AAAA');
     v_length := UTL_RAW.length(v_buffer_raw);
     dbms_lob.writeappend(v_new_blob, v_length, v_buffer_raw);
     insert into t1 values ('tmp\FileA.txt',v_new_blob);                         
     dbms_lob.freetemporary(v_new_blob);
     dbms_lob.createtemporary(v_new_blob,true);
     v_buffer_raw := UTL_RAW.cast_to_raw('BBBBBBBBB');
     v_length := UTL_RAW.length(v_buffer_raw);
     dbms_lob.writeappend(v_new_blob, v_length, v_buffer_raw);
     insert into t1 values ('tmp\FileB.txt',v_new_blob);                         
     dbms_lob.freetemporary(v_new_blob);
     dbms_lob.createtemporary(v_new_blob,true);
     v_buffer_raw := UTL_RAW.cast_to_raw('CCCCCCCCCCCCC');
     v_length := UTL_RAW.length(v_buffer_raw);
     dbms_lob.writeappend(v_new_blob, v_length, v_buffer_raw);
     insert into t1 values ('tmp\FileC.txt',v_new_blob);                         
     dbms_lob.freetemporary(v_new_blob);
     dbms_lob.createtemporary(v_new_blob,true);
     v_buffer_raw := UTL_RAW.cast_to_raw('DDDDDDDDDDDDDDDDDDDDDDDDDD');
     v_length := UTL_RAW.length(v_buffer_raw);
     dbms_lob.writeappend(v_new_blob, v_length, v_buffer_raw);
     insert into t1 values ('tmp\FileD.txt',v_new_blob);                         
     dbms_lob.freetemporary(v_new_blob);     
     commit;
     select file_name, file_blob into v_file_name, v_new_blob
          from t1 where file_name = 'tmp\FileA.txt';
     zz_zip.add1file(b_zipped_blob, v_file_name, v_new_blob);
     select file_name, file_blob into v_file_name, v_new_blob
          from t1 where file_name = 'tmp\FileB.txt';
     zz_zip.add1file(b_zipped_blob, v_file_name, v_new_blob);     
     select file_name, file_blob into v_file_name, v_new_blob
          from t1 where file_name = 'tmp\FileC.txt';
     zz_zip.add1file(b_zipped_blob, v_file_name, v_new_blob);     
     zz_zip.finish_zip(b_zipped_blob);
     zip_files := zz_zip.get_file_list( b_zipped_blob );
     for i in zip_files.first() .. zip_files.last
     loop
          dbms_output.put_line( zip_files( i ) );
     end loop;
     dbms_output.put_line('--');      
     -- Output
     FileA.txt
     FileB.txt
     FileC.txt
     -- Save zip in t1
     insert into t1 values ('ZipZZ.zip',b_zipped_blob);
     commit;     
     -- Create new zip file and add ZipZZ.zip and FileD.txt
     b_zipped_blob := null;
     select file_name, file_blob into v_file_name, v_new_blob
          from t1 where file_name = 'ZipZZ.zip';
     zz_zip.add1file(b_zipped_blob, v_file_name, v_new_blob);     
     select file_name, file_blob into v_file_name, v_new_blob
          from t1 where file_name = 'tmp\FileD.txt';
     zz_zip.add1file(b_zipped_blob, v_file_name, v_new_blob);     
     zz_zip.finish_zip(b_zipped_blob);
     zip_files := zz_zip.get_file_list( b_zipped_blob );
     for i in zip_files.first() .. zip_files.last
     loop
          dbms_output.put_line( zip_files( i ) );
     end loop;
     dbms_output.put_line('--');      
     /* output
     ZipZZ.zip
     tmp\FileD.txt
     -- save ZipXX.zip
     insert into t1 values ('ZipXX.zip',b_zipped_blob);
     commit;     
end;
--Test with other zip files.
insert into t1 values ('File1.zip',null);
commit;
-- I've created a small zip file File1.zip using Winzip. It contains only 1 small text file File1.txt
-- I use toad to insert into blob column.
declare
v_new_blob blob;
v_file_name varchar2(100);
v_buffer_raw raw(1000);
v_length integer;
b_zipped_blob BLOB;
zip_files zz_zip.file_list;
t_file blob;
begin
     select file_name, file_blob into v_file_name, v_new_blob
          from t1 where file_name = 'File1.zip';
     dbms_output.put_line('Blob length: '||dbms_lob.getlength(v_new_blob));
     zz_zip.add1file(b_zipped_blob, v_file_name, v_new_blob);     
     zz_zip.finish_zip(b_zipped_blob);
     zip_files := zz_zip.get_file_list( b_zipped_blob );
     for i in zip_files.first() .. zip_files.last
     loop
          dbms_output.put_line( zip_files( i ) );
     end loop;
     dbms_output.put_line('--');
     -- save new file as Zip1.zip
     insert into t1 values ('ZipFF.zip',b_zipped_blob);
     commit;     
end;      
     Output
     Blob length: 1855
     File1.zip
     File1.txt
Now, new zip file contains both File1.zip and File.txt.
My expected result was just File1.zip
Thanks.

Your first example looks like I would expect (or do I miss something?).
Your second example is strange, but it I can't reproduce it. If I zip a zipfile with my package it contains only the zipfile:
declare
  my_zip blob;
  new_zip blob;
  zip_files as_zip.file_list;
  function file2blob(
    p_dir in varchar2
  , p_file_name in varchar2
    return blob
  is
    file_lob bfile;
    file_blob blob;
  begin
    file_lob := bfilename( p_dir
                         , p_file_name
    dbms_lob.open( file_lob
                 , dbms_lob.file_readonly
    dbms_lob.createtemporary( file_blob
                            , true
    dbms_lob.loadfromfile( file_blob
                         , file_lob
                         , dbms_lob.lobmaxsize
    dbms_lob.close( file_lob );
    return file_blob;
  exception
    when others
    then
      if dbms_lob.isopen( file_lob ) = 1
      then
        dbms_lob.close( file_lob );
      end if;
      if dbms_lob.istemporary( file_blob ) = 1
      then
        dbms_lob.freetemporary( file_blob );
      end if;
      raise;
  end;
begin
  my_zip := file2blob( 'MY_DIR', 'as_fop.zip' );
  dbms_output.put_line('zip file to start with');
  zip_files := as_zip.get_file_list( my_zip );
  for i in zip_files.first() .. zip_files.last
  loop
    dbms_output.put_line( zip_files( i ) );
  end loop;
  dbms_output.put_line('--');
--  now create a new zip file containing the existing zip file as_fop.zip
  as_zip.add1file( new_zip, 'as_fop.zip', my_zip );
  as_zip.finish_zip( new_zip );
--  see what's in the new zip
  dbms_output.put_line('zip file containing a zipfile');
  zip_files := as_zip.get_file_list( new_zip );
  for i in zip_files.first() .. zip_files.last
  loop
    dbms_output.put_line( zip_files( i ) );
  end loop;
  dbms_output.put_line('--');
end;
Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
zip file to start with
as_fop.sql
zip file containing a zipfile
as_fop.zip
PL/SQL procedure successfully completed.
ANTON@XE>Anton

Similar Messages

  • Error when creating ZIP file (return value 2 when IGS was called)

    Hello All
    I attempted to Schedule a Query to the Portal folders and executes fine.  However when it's scheduled to and email, I am getting this message
    'Error when creating ZIP file (return value 2 when IGS was called)'
    Any ideas?
    Thanks ...BK

    Hello Kai
    Thanks very much for the info.  how would I know what patch the IGS is?
    Thank you.
    Regards..BK

  • Want To create Zip file  using java,And Unzip without Java Program

    I want to create a zip text file using java, I know Using ZipOutputStream , we can create a zip file, , But i want to open that zip file without java program. suppose i use ZipOutputStream , then zip file is created But for unZip also difftrent program require. We cant open that zip file without writing diff java program.
    Actually i have one text file of big size want to create zip file using java , and unzip simply without java program.Its Possible??
    Here is one answer But I want to open that file normal way(
    For Exp. using winzip we can create a zip file and also open simply)
    http://forum.java.sun.com/thread.jspa?threadID=5182691&tstart=0

    Thanks for your Reply,
    I m creating a zip file using this program, Zip file Created successfully But when im trying to open .zip file i m getting error like "Canot open a zip file, it does not appear to be valid Archive"
    import java.io.*;
    import java.util.zip.*;
    public class ZipFileCreation
         public static void main (String argv[])
         try {
         FileOutputStream fos = new FileOutputStream ( "c:/a.zip" );
         ZipOutputStream zip = new ZipOutputStream ( fos );
         zip.setLevel( 9 );
         zip.setMethod( ZipOutputStream.DEFLATED );
    //     get the element file we are going to add, using slashes in name.
         String elementName = "c:/kalpesh/GetSigRoleInfo092702828.txt";
         File elementFile = new File ( elementName );
    //     create the entry
         ZipEntry entry = new ZipEntry( elementName );
         entry.setTime( elementFile.lastModified() );
    //     read contents of file we are going to put in the zip
         int fileLength = (int)elementFile.length();
         System.out.println("fileLength = " +fileLength);
         FileInputStream fis = new FileInputStream ( elementFile );
         byte[] wholeFile = new byte [fileLength];
         int bytesRead = fis.read( wholeFile , 0 /* offset */ , fileLength );
    //     checking bytesRead not shown.
         fis.close();
    //     no need to setCRC, or setSize as they are computed automatically.
         zip.putNextEntry( entry );
    //     write the contents into the zip element
         zip.write( wholeFile , 0, fileLength );
         zip.closeEntry(); System.out.println("Completed");
    //     close the entire zip
         catch(Exception e) {
    e.printStackTrace();
    }

  • Create Zip File In Windows and Extract Zip File In Linux

    I had created a zip file (together with directory) under Windows as follow (Code are picked from [http://www.exampledepot.com/egs/java.util.zip/CreateZip.html|http://www.exampledepot.com/egs/java.util.zip/CreateZip.html] ) :
    package sandbox;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    * @author yan-cheng.cheok
    public class Main {
         * @param args the command line arguments
        public static void main(String[] args) {
            // These are the files to include in the ZIP file
            String[] filenames = new String[]{"MyDirectory" + File.separator + "MyFile.txt"};
            // Create a buffer for reading the files
            byte[] buf = new byte[1024];
            try {
                // Create the ZIP file
                String outFilename = "outfile.zip";
                ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename));
                // Compress the files
                for (int i=0; i<filenames.length; i++) {
                    FileInputStream in = new FileInputStream(filenames);
    // Add ZIP entry to output stream.
    out.putNextEntry(new ZipEntry(filenames[i]));
    // Transfer bytes from the file to the ZIP file
    int len;
    while ((len = in.read(buf)) > 0) {
    out.write(buf, 0, len);
    // Complete the entry
    out.closeEntry();
    in.close();
    // Complete the ZIP file
    out.close();
    } catch (IOException e) {
    e.printStackTrace();
    The newly created zip file can be extracted without problem under Windows, by using  [http://www.exampledepot.com/egs/java.util.zip/GetZip.html|http://www.exampledepot.com/egs/java.util.zip/GetZip.html]
    However, I realize if I extract the newly created zip file under Linux, using modified version of  [http://www.exampledepot.com/egs/java.util.zip/GetZip.html|http://www.exampledepot.com/egs/java.util.zip/GetZip.html] . The original version doesn't check for directory using zipEntry.isDirectory()).public static boolean extractZipFile(File zipFilePath, boolean overwrite) {
    InputStream inputStream = null;
    ZipInputStream zipInputStream = null;
    boolean status = true;
    try {
    inputStream = new FileInputStream(zipFilePath);
    zipInputStream = new ZipInputStream(inputStream);
    final byte[] data = new byte[1024];
    while (true) {
    ZipEntry zipEntry = null;
    FileOutputStream outputStream = null;
    try {
    zipEntry = zipInputStream.getNextEntry();
    if (zipEntry == null) break;
    final String destination = Utils.getUserDataDirectory() + zipEntry.getName();
    if (overwrite == false) {
    if (Utils.isFileOrDirectoryExist(destination)) continue;
    if (zipEntry.isDirectory())
    Utils.createCompleteDirectoryHierarchyIfDoesNotExist(destination);
    else
    final File file = new File(destination);
    // Ensure directory is there before we write the file.
    Utils.createCompleteDirectoryHierarchyIfDoesNotExist(file.getParentFile());
    int size = zipInputStream.read(data);
    if (size > 0) {
    outputStream = new FileOutputStream(destination);
    do {
    outputStream.write(data, 0, size);
    size = zipInputStream.read(data);
    } while(size >= 0);
    catch (IOException exp) {
    log.error(null, exp);
    status = false;
    break;
    finally {
    if (outputStream != null) {
    try {
    outputStream.close();
    catch (IOException exp) {
    log.error(null, exp);
    break;
    if (zipInputStream != null) {
    try {
    zipInputStream.closeEntry();
    catch (IOException exp) {
    log.error(null, exp);
    break;
    } // while(true)
    catch (IOException exp) {
    log.error(null, exp);
    status = false;
    finally {
    if (zipInputStream != null) {
    try {
    zipInputStream.close();
    } catch (IOException ex) {
    log.error(null, ex);
    if (inputStream != null) {
    try {
    inputStream.close();
    } catch (IOException ex) {
    log.error(null, ex);
    return status;
    *"MyDirectory\MyFile.txt" instead of MyFile.txt being placed under folder MyDirectory.*
    I try to solve the problem by changing the zip file creation code to
    +String[] filenames = new String[]{"MyDirectory" + "/" + "MyFile.txt"};+
    But, is this an eligible solution, by hard-coded the seperator? Will it work under Mac OS? (I do not have a Mac to try out)
    p/s To be honest, I do a cross post at  [http://stackoverflow.com/questions/2549766/create-zip-file-in-windows-and-extract-zip-file-in-linux|http://stackoverflow.com/questions/2549766/create-zip-file-in-windows-and-extract-zip-file-in-linux] Just want to get more opinion on this.
    Edited by: yccheok on Apr 26, 2010 11:41 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Your solution lies in the File.separator constant; this constant will contain the path separator that is used by the operating system. No need to hardcode one, Java already has it.
    edit: when it comes to paths by the way, I have the bad habit of always using the front slash ( / ). This will also work under Windows and has the added benefit of not needing to be escaped.

  • Want to view the created zip file via Bursting in Oracle Apps

    Hello,
    I' ve created a Bursting control file and invoked the concurrent request (XML Publisher Report Bursting Program, XDOBURSTREP) within the after-report trigger in oracle reports.
    My Bursting-Control file as follows:
    <xapi:requestset xmlns:xapi="http://xmlns.oracle.com/oxp/xapi" type="bursting">
    <xapi:request select="/XXMI_OM_QUOTE/LIST_G_ORDERS/G_ORDERS">
    <xapi:delivery>
    <xapi:filesystem id="file1" output="/usr/tmp/DEV1/${QUOTE_NO}"></xapi:filesystem>
    </xapi:delivery>
    <xapi:document output-type="pdf" delivery="123">
    <xapi:template type="xsl-fo" location="xdo://XXMI.XXMI_OM_QUOTE.en.US">
    </xapi:template>
    </xapi:document>
    </xapi:request>
    </xapi:requestset>
    It works fine. e.g. Bursting creates two pdf-files and one zip file in unix, which I can see when pushing the View Output of the request(XML Publisher Report Bursting Program):
    <?xml version="1.0" encoding="UTF-8" ?>
    - <BURS_REPORT>
    <REQUESTID>643527</REQUESTID>
    <PARENT_REQUESTID>643525</PARENT_REQUESTID>
    <REPORT_DESC>XXMI OM Quote</REPORT_DESC>
    <OUTPUT_FILE>/u00/erp/dev1APP/inst/apps/DEV1/logs/appl/conc/out/o643527.zip</OUTPUT_FILE>
    - <DOCUMENT_STATUS>
    <KEY />
    <OUTPUT_TYPE>pdf</OUTPUT_TYPE>
    <DELIVERY>FILESYSTEM</DELIVERY>
    <OUTPUT>/usr/tmp/DEV1/10000012.pdf</OUTPUT>
    <STATUS>success</STATUS>
    <LOG />
    </DOCUMENT_STATUS>
    - <DOCUMENT_STATUS>
    <KEY />
    <OUTPUT_TYPE>pdf</OUTPUT_TYPE>
    <DELIVERY>FILESYSTEM</DELIVERY>
    <OUTPUT>/usr/tmp/DEV1/10000026.pdf</OUTPUT>
    <STATUS>success</STATUS>
    <LOG />
    </DOCUMENT_STATUS>
    </BURS_REPORT>
    But instead of this XML-output I wish a link to the file on unix. How can I link <OUTPUT_FILE>/u00/erp/dev1APP/inst/apps/DEV1/logs/appl/conc/out/o643527.zip</OUTPUT_FILE> within the view Output-Button of this request?
    Thanks in advance for any clues

    That is not how bursting works in EBS.
    The View Output from XDOBURSTREP is the Bursting Status Reprot.
    The bursted results are (potentially) multiple files so cannot be linked to view output.
    Depending upon the delivery channel chosen you have to either read the email, check the fiel system or printer, to see the results.
    The delivery channel bypasses the standard EBS request view.
    Kevin

  • Can I create a file using pl/sql code in application server ?

    Hi
    I wanted to create a file(any kind of file .txt .csv .exe etc..) using pl/sql code in application server?
    Please help me with an example...in this regard
    Regards
    Sa

    864334 wrote:
    I wanted to create a file(any kind of file .txt .csv .exe etc..) using pl/sql code in application server?And how is this "file" to be delivered?
    Files can be created by PL/SQL code and stored in the Oracle database as CLOBs. This a fairly easy and robust process. It runs entirely in the database. It conforms to transaction processing. The "file" (as a CLOB) resides in the database and can thus be secured via database security, is part of database backups and so on.
    The basic issue is how to deliver the contents of the CLOB to the user. If via FTP, then the database can directly FTP the contents of the CLOB to the FTP server as a file. If via HTTP, the database can deliver the CLOB as a HTTP download directly to the web browser.
    If the client is Java or .Net, then the CLOB contents can be delivered via SQL or DBMS_LOB or a custom PL/SQL interface.
    In such cases, there is no need to step outside the secure and flexible database environment and create a physical o/s file in the wild (outside the controls of database security, data integrity and transaction processing). This is thus recommended and is the preference.

  • How to read a Zip file in PL/SQL program

    Hi,
    I was Reading a ".csv" file from a web URL eg. "www.aba.com/zxc.csv" in my PL/SQL procedure using UTL_HTTP package and loading data in my DB.
    Now that file is in .zip format, is there any way that I can still read that .csv.zip file through my PL/SQL procedure. Because now I have to download it first then
    unzip it and then I am loading it into my DB using UTL_FILE package instead I want to do it automatically as I was doing it before when it was not zipped.
    Thanks & Regards
    Sanjay

    Peters solution is a great, nice alternative - you should consider it.
    But your present solution reads the data from the web using UTL_HTTP into a CLOB I presume? So you are not hitting the file system at all?
    If it is not an option for you to go to the file system, then it is possible that you can use [url http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/u_compr.htm#BGBBCDDI]UTL_COMPRESS package.
    That is (maybe) a possibility if the zip file only contains one file - it cannot handle if the zip file is a zip archive with several files in it.
    You could try doing your UTL_HTTP load into a BLOB and then call UTL_COMPRESS.LZ_UNCOMPRESS to unzip that BLOB into another BLOB.
    I'm not guaranteeing it will work, but it may be worth a try if you cannot do it Peters way ;-)

  • How to create Batch file to execute sql scripts

    Hi friends,  
          i want to create batch file to execute all my .sql scripts.
    I have all table ( all table scripts in single file ) ,Udds ( all udds in single file ) ,Stored procedures( separate file for each SPs ),Functions ( Separate file for each Functions ),Triggers and views scripts in .SQL file.   
    can anybody tell me how to create batch file for executing all these scripts in sql server ?.   
       while executing, it should ask Database name,server name, password. if these details are given then it should execute my all scripts in given database
    , if any error thrown then that error and procedure name alone have to move to separate log file..
    Please help me if this possible or any other easy way to do this..
    Thanks - Ravi

    Hi  Mate.
    can i save the below details in my batch file parmantly, so that i don't need to provide the details agains again in CMD while i execute this. Please help
    set /p SName=Server Name :
    set /p UName=User Name :
    set /p Pwd=Password :
    set /p DbName=Database Name
    If  i am providing the details before execution of this bat file it will throw error.

  • Problem in creating zip file.

    Hi,
    I am using the zip package to create a zip file.The code is given below :
      ZipOutputStream out = new ZipOutputStream(new
      BufferedOutputStream(new FileOutputStream("d:\\abc\\target.zip")));
        byte[] data = new byte[1000];              
        BufferedInputStream in = new BufferedInputStream
    (new FileInputStream("d:\\abc\\xyz.log"));
        int count;
       out.putNextEntry(new ZipEntry("d:\\abc\\target.zip"));
       while((count = in.read(data,0,1000)) != -1)
       out.write(data, 0, count);
       in.close();
       out.flush();
       out.close();The problem is that the zip file created is having no files when i try to zip files from locations other than the program file location ie other than current drive.
    Could you please suggest me a solution so that it zips file from any location. Thanks in advance.

    BRAVO wrote:
    Hi,
    I am using the zip package to create a zip file.The code is given below :
    ZipOutputStream out = new ZipOutputStream(new
    BufferedOutputStream(new FileOutputStream("d:\\abc\\target.zip")));
    byte[] data = new byte[1000];              
    BufferedInputStream in = new BufferedInputStream
    (new FileInputStream("d:\\abc\\xyz.log"));
    int count;
    out.putNextEntry(new ZipEntry("d:\\abc\\target.zip"));
    while((count = in.read(data,0,1000)) != -1)
    out.write(data, 0, count);
    in.close();
    out.flush();
    out.close();The problem is that the zip file created is having no files when i try to zip files from locations other than the program file location ie other than current drive.
    Could you please suggest me a solution so that it zips file from any location. Thanks in advance.My advice would be to tryout something as given below and checkout whether that can
    a). Give you Exception Message/stack trace if an error has occured
    b). Check whether the appropriate code change works
    public compressFile(String inputFile,String destFile){
    ZipOutputStream out = null;
    byte[] data = null;
    BufferedInputStream in = null;
    try{
        out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(destFile)));
        data = new byte[1024];
         try{               
             in = new BufferedInputStream(new FileInputStream(inputFile));
             int count = -1;
             out.putNextEntry(new ZipEntry(inputFile));
             while((count = in.read(data)) > 0){     
                out.write(data, 0, count);
           }catch(Exception e){
               System.err.println(e.getMessage());
               e.printStackTrace();
           }finally{       
                  if(in != null)
                     try{in.close();}catch(Exception ex){}
       out.flush();
    }catch(Exception exp){
        System.err.println(exp.getMessage());
        exp.printStackTrace();
    }finally{
      if(out != null)
         try{out.close();}catch(Exception e){}
       out = null;
       in = null;
    }in order to compress the file we can call the method something like
    compressUtilObj.compressFile("d:\\abc\\target.zip","d:\\abc\\xyz.log");Hope that helps :)
    REGARDS,
    RaHuL

  • Creating zipped file which contain multiple files

    hi all,
    i have a problem which i would like some advice about:
    i need to recieve from a FTP server multiple files and then zip them all in one big zip file.
    now i checked the forums and all i found is using PayloadZipBean which in all the examples create a zip file with one .txt in it.
    is it possible to create multiple files in the zip using this module?
    another problem if the one big zip file is what if each of the files inside the zip file has it's own mapping...
    i think a BPM is a must here and a parallel one also with a correlation...
    i would like if it's possible to do something different as the correlation between the files is a bit complicated?
    regards and thanks a lot,
    Roi Grosfeld

    First,
    I would like to understand your requirement. Is it to only download and zip the files in to one file? XI is not the solution. A OS level script or some C program is what I would use for that which calls some FTP APIs.
    If you requirement is to get different files with different format but want to send them to one desintation which accepts files in only one format, I would not consider zipping them into one file and again unzipping then and executing a mapping XI. Instead, I would have different file adapter for each type of the file and use as many sender agreements with diffrent mappings.
    Hope it made some sense..!!
    VJ

  • ZipException creating zip file

    I am trying to modify a zip file, by creating a new zip file and copying the entries over selectively. I use the following code:
    try
                   zipFile = new ZipFile(args[0]);
                   zos = new ZipOutputStream(new FileOutputStream(args[1]));
                   entries = zipFile.entries();
                   while(entries.hasMoreElements())
                        entry = (ZipEntry)entries.nextElement();
                        if (entry.getName().endsWith(".class") || entry.isDirectory() ||
                                  entry.getName().endsWith(".MF"))
                             zos.putNextEntry(entry);
                   zipFile.close();
                   zos.close();
              catch (IOException ioe)
                   System.err.println("Unhandled exception:");
                   ioe.printStackTrace();
                   System.err.println(entry);
                   return;
    However it throws an exception for the second entry that it encounters:
    invalid entry size (expected 10804 but got 0 bytes)
         at java.util.zip.ZipOutputStream.closeEntry(Unknown Source)
         at java.util.zip.ZipOutputStream.putNextEntry(Unknown Source)
         at delPNGsFromJar.main(delPNGsFromJar.java:34)
    It doesn't matter which entry it is, it always fails on the seconds.
    Anyone have any ideas?

    A ZipEntry only contains data associated with the entry, it does not contain any actual data. In addition to putting an entry with "putNextEntry" you have to write its data.
    You do this by getting the entry's InputStream from the ZipFile object, and writing what you read from it to the ZipOutputStream. Don't forget to close the entry when you're done.

  • Creating ZIP files of iPhoto 08 albums

    Very simply, how can I create a ZIP file of an iPhoto 08 album so that the pictures can be emailed?

    Very simply,
    Select the pic in the iPhoto Window and go File -> Export and export them to a Folder on the desktop. Zip and email that.
    Regards
    TD

  • Creating Zip File

    I created a zip file by clicking on "Creative Archive," but the file size is still the same. Am I doing something wrong or is there another way to shrink the file size?

    Hi astinn,
    What type of file you're trying to compress and what type of compression program you're using makes a lot of difference.
    As a quick test, I zipped a handful of PDF files on my drive. The resulting .zip file was indeed not much different than the total of the originals. What the PDF contains would also make a difference. If it's mostly just text, than the PDF is already highly compressed. If it has images in it, then it depends on if they're high res (300 dpi) press ready images, which will compress quite a bit, or already highly compressed embedded JPEGs.
    Zip is very good at some things, not very good at others. Likewise with Stuffit. It can't compress things like Windows .wmf files at all. Whereas RAR will cut the size of that same file by about half.

  • Failed to create zip file - did not free space

    Hi,I tried to zip the inside of my camera folder and naturally did not have enough space.1. Creation of the zip file failed.2. Shows me that there is no more room left on device, i.e. the space was not freed.3. Can not locate the zip file it tried to create (it did not appear in the same folder as "camera" and can't find it anywhere else either). Can anyone help, please, can't copy files anywhere because no space left and don't want to delete anything. Thanks in advance,Dario

    In regards to your original problem, but I can see two solutions without Link. 1, get an SD card and transfer some content over. The phone has finite space and this is the only way you can access storage from a computer without Link, so it is then only way to back up files (did I mention that is important yet?). 2, download Ghost Commander from the app world. It is a vastly more powerful file browser that can allow you to see your device storage particulars. I have none idea where a temporary ZIP file is located however, so this is not choice #1.

  • Image Capture creating zip files instead of regular files

    I've been using Image Capture for many years. For some reason, all of a sudden, all my scans are being put into a zip file instead of as a regular file. I'd like to have Image Capture make regular files again such as pdf etc.  What do I do?
    Does this have anything to do with going to OS Yosemite 10.10?

    Hi
    appzapper & such are pretty flaky at removing things usefully, imo.
    Use the uninstaller for speed download - http://www.yazsoft.com/products/speed-download/faqs/?how-to-un-install-speed-dow nload-properly
    or get a hold of FindAnyFile or easyfind & search for Growl & Speeddownload & yazsoft - but from all I hear, the uninstaller works fine.
    Failing that, Safari's settings plist file isn't in caches
    Home/Library/Preferences/com.apple.safari.plist
    is the place
    & if you're still stuck, test & maybe download another browser using a New User Account.

Maybe you are looking for

  • CI issues on Linux - CentOS + Hudson

    Hi there, I got some issues to generate the Junit reports, it gets up to "Waiting for client connection" then do nothing for a few seconds. When it gets back this is what I get in the console: runUnitTests:      [java] Loading configuration file /opt

  • Inspire P580 Connecting to Laptop?

    I recently got a new laptop and have moved, so I had to sell my PC. I wanted to keep my P580 speakers, so I brought them in an put them next to my laptop. I took one look and saw a problem. My laptop has input jack thing (The place where you would pl

  • Why an imported SWF created in Flash CS5 doesn't works fine?

    perhaps I am not lucky. I find no answer.. perhaps im a noob (daaaah)  please if you can help it would be appreciated! I'm new in flash and flash catalyst.. but i'm not bad at all hehe. After publishing a swf from flash CS5 (that works perfect when i

  • Downloading programs in 10.4.6

    I'm trying to download and open a program on a G4 running 10.4.6. but the default application is set to iTunes. It's an .exe download, how do I make it so I can open and run the download>?

  • Using Interface Builder to Inspect a New Object?

    I am having a major frustration following a Stanford demo on using Interface Builder. The demo shows how to create a simple slider object with a value. But when the demo pulls up the Inspector Window to examine the new Object, in the Stanford demo th