Results 1 to 6 of 6
  1. #1
    yurabita is offline Member
    Join Date
    Aug 2010
    Posts
    4
    Rep Power
    0

    Default add to a zip file without copying it.

    My program should work with a zip file about 300 mb.

    the zip is updated many times during the execution and I need a way to introduce the zip files without copying the entire file again.

    I tried the library "TrueZip" with this code:

    Java Code:
    import de.schlichtherle.io.File;
    public class Main {
    
        public static void main(String[] args) {
    
            File zip = new File ("c:/zip/zip.zip");
            File add = new File ("c:/prueba.txt");
            add.archiveCopyTo(new File (zip,"prueba.txt"));
    
        }
    
    }
    I tried not to create a new file in the archiveCopyTo method () but if you tell the original zip file does not flinch

    can add files but it takes about 16 seconds to add a 1kb text file to my 300mb zip that creates the zip again.

    Does anyone have a solution to my problem?

    Sorry for my bad English.

    thanks

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,524
    Blog Entries
    7
    Rep Power
    20

    Default

    As you could've seen in the API documentation for all the Zip* entries there is no functionality implemented for just updating entries in a .zip file.

    kind regards,

    Jos

  3. #3
    yurabita is offline Member
    Join Date
    Aug 2010
    Posts
    4
    Rep Power
    0

    Default

    thanks for response :D

    there is some unofficial library? or all to copy the entire file again?

    :(

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,524
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by yurabita View Post
    thanks for response :D

    there is some unofficial library? or all to copy the entire file again?

    :(
    I don't know what that 'TrueZip' library does but given the time it takes to update an entry my guess is that it rewrites the entire .zip file when you want to 'update' a single entry.

    kind regards,

    Jos

  5. #5
    yurabita is offline Member
    Join Date
    Aug 2010
    Posts
    4
    Rep Power
    0

    Default

    I'm afraid I'm going to have to program in Python, I still hear some possible solutions, as I would like to develop in Java

    Very thanks Jos!

  6. #6
    yurabita is offline Member
    Join Date
    Aug 2010
    Posts
    4
    Rep Power
    0

    Default

    Hello!

    I found half a solution.

    I used the Jython library.
    add python zip files is very simple (3 lines).

    I am new to java so I do not know if it will be well structured or I'm missing something. for now I've tried works

    I leave a simple example if someone has the same problem.

    Java Code:
        public static void addFileToZip(String zipRoute, String addRoute){
         PythonInterpreter py = new PythonInterpreter();
         
         py.exec("import zipfile");
         py.exec("z = zipfile.ZipFile('"+zipRoute+"','a')");
         py.exec("z.write('"+addRoute+"')");
         py.exec("z.close()");
    
        }

Similar Threads

  1. Copying a file (.docx) from computers
    By chyrl in forum Networking
    Replies: 3
    Last Post: 07-02-2010, 02:02 PM
  2. problems copying a file
    By atom86 in forum Advanced Java
    Replies: 16
    Last Post: 10-01-2009, 02:40 PM
  3. Creating Folder in JAVA and Copying File
    By fnoman in forum New To Java
    Replies: 8
    Last Post: 10-18-2008, 07:33 AM
  4. Replies: 13
    Last Post: 01-09-2008, 06:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •