Adding a file into existing zip file

I need a add a file into existing zip file. and write into printwriter.
How to do it?
Waiting for the reply.
Thanks and Regards,
Narayanan. G

Narayanan.G wrote:
I need a add a file into existing zip file.API: [ZipOutputStream#putNextEntry()|http://java.sun.com/javase/6/docs/api/java/util/zip/ZipOutputStream.html#putNextEntry%28java.util.zip.ZipEntry%29]
Tutorial: [http://java.sun.com/developer/technicalArticles/Programming/compression/].
and write into printwriter.Writing a zip file into printwriter? Huh? Please elaborate.

Similar Messages

  • How to zip multi files into one zip file in ABAP

    hi all:
    As you know, ABAP has CL_ABAP_GZIP class to support zip file function. But it only support one file zip. If I want to zip two files into one zip file, how to do it?
    thanks.

    Hi,
    <li>If you know how to zip one file,  to zip two files , you can follow the below steps.
    DATA:g_zipper     TYPE REF TO cl_abap_zip.
    "create our zipper object
    CREATE OBJECT g_zipper.
    "add 1st file to zip
    CALL METHOD g_zipper->add
       EXPORTING
         name    = file_name
         content = content_x.
      "add 2nd file to zip
    CALL METHOD g_zipper->add
       EXPORTING
         name    = file_name
         content = content_y.
    "save zip
    CALL METHOD g_zipper->save
       RECEIVING
         zip = zip.
    Thanks
    Venkat.O

  • Broken: PS script to recursively zips files into one zip file

    Hi
    I'd like a script which zips all files and subfolders older than a specified date.
    I've have spent a fair bit of time hacking with no luck.
    I'd greatly appreciate any help.
    AJ
    PS. This script seems to do the trick -
     $folder = "C:\temp2\" 
     $zipFileName = "C:\temp\test3.zip" 
     $zip_date = Get-Date "6/5/2014"
     set-content $zipFileName ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18)) 
     $ZipFile = (new-object -com shell.application).NameSpace($zipFileName) 
     Get-ChildItem $folder | foreach {$zipFile.CopyHere($_.fullname)} 
    However, when I enter where clause  only the top folder is zipped?
    Get-ChildItem $folder| Where-Object { $_.LastWriteTime -lt $zip_date }  | foreach {$zipFile.CopyHere($_.fullname)} 
    AJ
    Ps. I'm using script from http://stackoverflow.com/questions/5641162/compress-files-in-folder-to-zip-file-by-using-ps

    Hi Rapido2,
    Thanks for your sharing =)

  • Write zip entry at end of existing zip file

    I need to open an existing zip file and write a new entry into the zip file. My code appears to overwrite the first entry wiping out the existing entries. I may need to provide an offset when I use the write method on the ZipOutputStream, but I am not sure how to calculate the offset based on the existing entries in the zip. Any ideas?
    // Currently I open a ZipOutputStream based on an existing file name
    FileOutputStream fos = new FileOutputStream("C:/temp/test.zip", true); // append to file
    ZipOutputStream zos = new ZipOutputStream(fos);
    ZipEntry ze = new ZipEntry("foo.txt");
    zos.putNextEntry(ze); // this doesn't seem to position the next write statement at the correct spot
    zos.write(ba); // where ba is byte array being generated with a FileInputStream from foo.txt

    You could try, but I'm not 100% it'll work...
    ZipFile zf = new ZipFile ("MyZip.zip");
    ZipOutputStream zout = new ZipOutputStream (new FileOutputStream ("MyZip2.zip");
    Enumeration enum = zf.entries ();
    while (enum.hasMoreElements ())
        // Not sure what's by nextElement...probably ZipEntry...
        ZipEntry zen = (ZipEntry) enum.nextElement ();
        zout.putNextEntry (zen);
        // Get the InputStream for the entry and then write out to the ZipOutputStream...
    // Now we are at the end of our new Zip...add our Entry...
    ZipEntry myen = new ZipEntry ("MyEntry.txt");
    // Again write out the content of the entry (MyEntry.txt file) to the ZipOutputStream...
    // Close the ZipOutputStream.
    // Get a file object to the MyZip2.zip and rename to MyZip.zip.This is messy and horrible but it seems to be the only way...I'm pretty sure that if you write directly to MyZip.zip then it would cause an IOException because you would be reading and writing at the same time...dodgy...
    At the moment all you are doing is creating a completely new Zip file, any existing file is just getting overwritten...

  • Loading data from .csv file into existing table

    Hi,
    I have taken a look at several threads which talk about loading data from .csv file into existing /new table. Also checked out Vikas's application regarding the same. I am trying to explain my requirement with an example.
    I have a .csv file and I want the data to be loaded into an existing table. The timesheet table columns are -
    timesheet_entry_id,time_worked,timesheet_date,project_key .
    The csv columns are :
    project,utilization,project_key,timesheet_category,employee,timesheet_date , hours_worked etc.
    What I needed to know is that before the csv data is loaded into the timesheet table is there any way of validating the project key ( which is the primary key of the projects table) with the projects table . I need to perform similar validations with other columns like customer_id from customers table. Basically the loading should be done after validating if the data exists in the parent table. Has anyone done this kind of loading through the APEX utility-data load.Or is there another method of accomplishing the same.
    Does Vikas's application do what the utility does ( i am assuming that the code being from 2005 the utility was not incorporated in APEX at that time). Any helpful advise is greatly appreciated.
    Thanks,
    Anjali

    Hi Anjali,
    Take a look at these threads which might outline different ways to do it -
    File Browse, File Upload
    Loading CSV file using external table
    Loading a CSV file into a table
    you can create hidden items in the page to validate previous records before insert data.
    Hope this helps,
    M Tajuddin
    http://tajuddin.whitepagesbd.com

  • Wht does safari combine multiple download into a zip file?

    I downloaded a MKV file from my NAS remotely which worked fine, however when i try to combine multiple files Safari seems to automatically ZIP the files which means I cannot tell how long the download will take or how much data is left to transfer.
    Anyone got any idea how to prevent Safari from putting multiple files into a zip?
    cheers

    I select multiple files from an online storage device, and select download. at this point for some reason when the download begins the files are combined into a zip file. when the download completes i then try to extract the zip file it often fails to extract.
    If I select any one of the selceted files individually, Safari download begins, and the completed download is not in a zip file format and the file is readable.
    I hope this makes sense to someone!
    cheers

  • Bursting in 10g into a Zip file.

    Hey,
    I wanted to know if its possible to burst a file in a zip file, like the email attachment should be a zip file. I have successfully done busrting with pdf, html and excel outputs for both EMAIL and FTP type. I want to know if Bursting into a zip file is possible. If yes, then please kindly tell me how to configure in the Burst.
    Thanks,
    Suvha Lama

    Hi,
    I have been analysing this. My scripts is to unzip the file and then delete the zip after unzipping.
    The script was working fine in the folder for some time. If we keep on testing the script. It's not deleting the zip after unzipping it.Which is causing PI to process the file multiple times so there are multiple files in backup folder.
    Any suggestion on this?

  • How to update an image file into existing file

    how to update an image file into existing file

    Hi,
    So, i assume you want to change one picture. On Stage, i have edgeAnimate (an image), and
    1) i am using the div tag.
    So: sym.$("edgeAnimate").css("background-image", "url(images/myImage.png)" ); will change my picture.
    Link: CSS properties.
    More CSS:
    sym.$("edgeAnimate").css( { "background-image": "url(images/myImage.png)", "background-size": "100% 100%", "background-repeat": "no-repeat", "cursor": "pointer" } );
    Using a path variable:
    var myPath = "images/myImage.png";
    sym.$("edgeAnimate").css( { "background-image": "url("+myPath+")", "background-size":"100% 100%", "background-repeat":"no-repeat", "cursor": "pointer" } );
    2) i am using the img tag.
    I can add a class using Edge Animate user interface.
    I choose one class name: "newImage".
    So:  sym.$(".newImage").css("background-image", "url(images/myImage.png)" ); will change my picture.
    Note: I assumed you don’t need to preload your picture.

  • I have a Probook running 10.7.5 and have compressed the 60Gb MobileSync folder into a zip file that is... 60Gb, the original file is still there so I have just lost another 60Gb of space.  What's going on?

    I have a Probook running 10.7.5 and have compressed the 60Gb MobileSync folder into a zip file that is... 60Gb, the original file is still there so I have just lost another 60Gb of space.  What's going on?

    Habibullah Allah Yar.
    Kabul Afghanistan.
    Head of Green Shaheen Group of Company's.
    Website: www.gsls-c.com.
    <Personal Information Edited by Host>

  • How to exreact multiple pdf files from a zip files from application server to presentation server

    Hello exprts,
    I am passing one pdf file and one text file to zip file in apllication server through my custom program and then downloading it using standard function module to my desktop. its working fine. Then I added  another pdf file to my zip file. But only single pdf file is getting download . So can you please help me regardiong this issue? 

    Dear Experts ,
    I finded out the way to extrcat pdf files in presentation server. But now my problem is that I am not able to add multiple pdf files in a zip file. When I am adding new pdf file then older one is not coming in read data set. So please kindly tell me how can I add multiple pdf file in my zip file and again I can get all the pdf files from here.

  • I need to send a group of files in a zip file. How do I do that?

    I have Microsoft Office for MAC and send to send a group of files.  I would like to compress them into a zip file.  Is there a way to do that with my MAC?

    Select all the files, control-click any one of them, and compress them.
    (64471)

  • Reading a Compressed File from a ZIP File, which is an entry of ZIP File

    Hello, Experts,
    Would it be possible somebody to help me with code example for the following problem?
    I want to read a compressed file from a ZIP file, which is an entry of ZIP File, without extacting/writing files on file system. Is this possible?
    Lets say we have a ZipFile1. There is ZipFile2 inside ZipFile1. And inside ZipFile2 is FileA. The scenario is reading FileA without extracting on file system.
    Thank you in advance for your help.
    Cheers
    RADY

    The classes you want to be using are java.util.zip.ZipInputStream and and ZipEntry from the same package. Construct the ZipInputStream with the input you have for the outer zip. Loop with ZipInputStream.getNextEntry until you find the inner zip you're looking for - that method returns a ZipEntry, and you get the name of the zip entry with ZipEntry.getName. Read the ZipInputStream from that point into some buffer, and read that buffer into a new ZipInputStream - rinse and repeat until you have the contents of the file in the zip in the zip...

  • Problem with compressing unicode file names in zip file

    Hi Everyone,
    I have a problem while compressing the unicode file name in a zip file. I used the below code for compressing the unicode files.
    String[] source = null;
    // C:\\TestData\\unicode_filename.txt :  unicode_filename.txt is the file created in japanesse language
    source = new String[] {"C:\\TestData\\temp_properties.xml","C:\\TestData\\unicode_filename.txt" };
    byte[] buf = new byte[1024];
    // Create the ZIP file
    String target = "C:\\TestData\\target.zip";
    ZipOutputStream out = new ZipOutputStream(new FileOutputStream(target));
    // Compress the files
    for (int i = 0; i < source.length; i++)
         FileInputStream in = new FileInputStream(source);
         // Add ZIP entry to output stream.
         String fileName;
         File tempFile;
         ZipEntry zipEntry = new ZipEntry(source[i]);
         fileName = zipEntry.getName();
    zipEntry = new ZipEntry(fileName);
    zipEntry.setMethod(ZipEntry.DEFLATED);
    getUTF8Bytes(source[i]);
    // here I'm unable to find the unicode files and not able to understand.
    out.putNextEntry(zipEntry);
    // 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();Please help me how to fix this issue.
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi,
    Thanks for your time for looking into my query.
    Please check the below code for debugging the issue and throw your comments/suggestions for fixing the issue.
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    public class ZipTest
      public static void main(String[] args) {
              String[] source = new String[] {"C:\\TestData\\APP_Properties.xml","C:\\TestData\\??.txt" };
              byte[] buf = new byte[1024];
              try {
                   // Create the ZIP file
                   String target = "C:\\TestData\\target.zip";
                   ZipOutputStream out = new ZipOutputStream(new FileOutputStream(target));
                   // Compress the files
                   for (int i = 0; i < source.length; i++) {
                        FileInputStream in = new FileInputStream(source);
                        // Add ZIP entry to output stream.
                        String fileName;
                        File tempFile;
                        ZipEntry zipEntry = new ZipEntry(source[i]);
                        fileName = zipEntry.getName();
                        zipEntry = new ZipEntry(fileName);
                        zipEntry.setMethod(ZipEntry.DEFLATED);
                        getUTF8Bytes(source[i]);
                        out.putNextEntry(zipEntry);
                        // 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();
         private static byte[] getUTF8Bytes(String s) {
              char[] c = s.toCharArray();
              FileOutputStream file;
              try {
                   file = new FileOutputStream("C:\\TestData\\output.txt", true);
                   int len = c.length;
                   // Count the number of encoded bytes...
                   int count = 0;
                   for (int i = 0; i < len; i++) {
                        int ch = c[i];
                        if (ch <= 0x7f) {
                             count++;
                        } else if (ch <= 0x7ff) {
                             count += 2;
                        } else {
                             count += 3;
                   // Now return the encoded bytes...
                   byte[] b = new byte[count];
                   int off = 0;
                   for (int i = 0; i < len; i++) {
                        int ch = c[i];
                        if (ch <= 0x7f) {
                             b[off++] = (byte) ch;
                             file.write((byte) ch);
                        } else if (ch <= 0x7ff) {
                             b[off++] = (byte) ((ch >> 6) | 0xc0);
                             file.write((byte) ((ch >> 6) | 0xc0));
                             b[off++] = (byte) ((ch & 0x3f) | 0x80);
                             file.write((byte) ((ch & 0x3f) | 0x80));
                        } else {
                             b[off++] = (byte) ((ch >> 12) | 0xe0);
                             file.write((byte) ((ch >> 12) | 0xe0));
                             b[off++] = (byte) (((ch >> 6) & 0x3f) | 0x80);
                             file.write((byte) (((ch >> 6) & 0x3f) | 0x80));
                             b[off++] = (byte) ((ch & 0x3f) | 0x80);
                             file.write((byte) ((ch & 0x3f) | 0x80));
                   file.write((byte) '\n');
                   file.write((byte) '\r');
                   file.flush();
                   file.close();
                   return b;
              } catch (FileNotFoundException e1) {
                   e1.printStackTrace();
              } catch (IOException e1) {
                   e1.printStackTrace();
              return null;
    }Thanks
    Aravind                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to read/unzip a specific file within a zip file

    Hi,
    I have a file within a zip file that contains a timestamp - I want to read this timestamp and then create a destination directory for the remaining zip files to be unzipped into. Since I know the name of the file with the timestamp in it I thought I could create a zipfile and use getEntry to get the entry but then other than getting the size and name of the file I can't do much more with it like read it unless I use a stream (zipinputstream) instead of a file (zipfile) - do I have this right?
    Does this mean to get the content I would have to loop through possibly all the files using the stream until I come across the one I want - then get the timestamp and loop through them all again to write them to the destination directory? Or am I reading this wrong - seems a bit round about.
    Any suggestions would be greatly appreciated.
    Thanks

    this works though - and you don't have to loop through all the files - just use the ZipFile:
    ZipEntry ze = zipfile.getEntry("path/to/file");
    BufferedReader br = new BufferedReader(new InputStreamReader(zf.getInputStream(ze)));
    line = br.readLine;Thanks!

  • How to unzip a zip file within another zip file

    I've got code that successfully processes a file within a zip file.
    But now the zip file can also contain other zip files. How can I
    process a zip nested within a zip without actually extracting the
    files? It looks like I need a ZipFile object to be able to take
    advantage of the zip classes for reading zip entries. But the
    ZipFile methods want as an argument an actual file, as opposed
    to some object in memory. I can read the 'inner' zip file into a
    ZipInputStream object, but then how do I make that available for
    processing as a ZipFile? I've searched all over and cannot find
    anything anywhere that talks about working with nested zip files.
    Does anyone have any sample code that does this? Thanks!

    I have successfully done it.
    You cannot have the code - it is proprietary.
    However here are a few pointers:
    o Use ZipStreams rather than ZipFile.
    o ZipStream is just a filter on a stream, so you can have a zipstream open, read a ZipEntry, then ask for a substream for the stuff up to the next ZipEntry. Put a second ZipStream on that substream.
    o As I recall you have to watch out that your inner ZipStream does not do a close. (Everything will get closed.) Instead, there is another ZipStream method that will close without closing all the underlying streams.
    Hope this helps.

Maybe you are looking for

  • File info in photoshop cc  doesn't work in osx 10.9.1

    I get a blank screen if I do File info, photoshop is blocked and I need to force quit Photoshop CC.  Any idea what I can do?

  • Timestamp error in one-to-one load

    Hi, I'm facing a issue while loading data from oracle view to sql table.Its simple one to one load.SRC-SQ-TGT Error:Message Code : WRT_8229Message : Database errors occurred: FnName: Execute -- [Informatica][ODBC SQL Server Wire Protocol driver]Times

  • DTW - UDT of Document Type

    Hi, Is it possible to implement DTW to UDT of Document Typeu2026 it displaying my UDT in Business object [drop down selection] selection... But while mapping fields itu2019s displaying code and name in target fields. I didnu2019t map this field with

  • Keyboard misbehaving/not responding for certain letters

    Last night my comp worked fine... Today, my keyboard [the wireless white one that came with it] wont respond to any letters on first line [q-o, but p works], nothing on 2nd letter line works, zxcvbnm, [those all work] and all the top number line work

  • Flex 3 Accordion

    Hi all, I have a unique requirement that needs to be put in pertaining to Flex Accordion. To start with I will have something like below, <mx:Accordion id="s" resizeToContent="true" width="100%" >   <mx:VBox id="v1" label="v1" height="200" >      <mx