Creating Zip  of multiple zip files without storing at perticular location

Hi,
I am having any number of files in folder called as OUTPUTFILES.And i want to create a zip file of that files e.g.If there are 3 files in outputfolder namly A,B,C..THen zips are as follows A.zip B.zip C.zip and after that i want one zipfile of these 3 zipfiles called as Main.zip without storing this A.zip,B.zip,C.zip files to any perticular location..CAn any on help me out ???
Thanks in advance,
Meghna

Ur posting wrong threads , This place is for java
peopleOnce again, shut up.

Similar Messages

  • 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();
    }

  • 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

  • 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.

  • 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

  • Process multiple documents in zip file without using ccBPM in PI

    Hi,
    Is it possible for PI to handle multiple documents within a zipped source file without the use of ccBPM?
    For example, I have an incoming source zip file containing 0.pdf, a,xml, z.pdf respectively,  After having the sender communication channel uncompress the zip file, each pdf file should be pushed to a directory on a file server, and the xml file should go through a message mapping.
    Is this possible to process all of the files without the use of ccBPM?
    Regards,
    Jim

    Hi Michal,
    Thank you for your response.  The example I provided is just one potential case.  In general, the zip file will always contain 1 xml file and 0-n PDFs, Word docs, or other types of documents.  Also, the first file in the zip may not always be the xml file, which is what I was trying to portray by my example.  Since I am not sure how many non-xml files will be included, I did not know if I could handle all of them directly, without ccBPM.
    At this point, I am leaning towards using a script preprocessor to uncompress the zip, then for each file found, push the xml file to an NFS channel which will process/map the xml, and push every other file type to another NFS channel to copy these documents to a predetermined directory on a predetermined server.
    What are your thoughts on this approach?
    Thanks and Regards,
    Jim

  • 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

  • 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

  • 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.

  • Download ZIP file without changing file extension

    I regularly download a zipped csv file, of the format: "filename.csv.gz". As the name does not change, Firefox adds a digit to distinguish it, so for example I get "filename.csv-3.gz". This is a pain as it changes the file extension which means that I cannot open the extracted file without first renaming it. I want to keep an archive of all the files, so deleting them each time isn't really an option, and neither is moving them to a different location each time. Is there any way the naming convention for downloads can be changed?

    I think you have to disable it in your Operating system:
    8dot3NameCreation
    [http://support.microsoft.com/kb/121007]

  • Find item in zip file without extracting

    Hi Guys!
    Weird question today!
    I'm looking for files like sin*.dat into a specific file-server folder that may contain subfolders and zip/7z folders.
    With powershell i'm not able to find this files into zip/7z folders and i can't unzip those folders for many reasons.
    Is there a way to find those files without unzip the folders?
    Thanks
    A

    Hi!
    Not Sure, i've got PS4 and update .Net with Windows update to 4.5.1 but it seems that PS don't recognise([System.IO.Compression.ZipFile].
    Using  this script http://blogs.technet.com/b/heyscriptingguy/archive/2013/11/02/powertip-find-if-computer-has-net-framework-4-5.aspx the
    result is true.
    What can i do?

  • 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

  • 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.

  • Is it possible to download a zipped file without unzipping it?

    I need to download zipped Joomla extensions from the Joomla website and then upload them to my LINUX website, via my Macintosh. The problem is that my Macintosh unzips the files. I then have to compress the files again before I upload them. This usually works without a problem but it'd be safer to download the file without unzipping them. Is there a way to do this? I can't find any Preference for zipping or compressing, or any documentation about controlling compression in Mac Help.

    try Safari > preferences > general. untick +open "safe" files+ ...
    ( *click on image to enlarge* )
    JGG

  • 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

Maybe you are looking for