Search code examples
javapythonjythonarchive

python (jython) archiving library


Is there a neat archiving library that automatically handles archiving a folder or directories for you out there? I am using Jython, so Java libs are also open for use. -UPDATE- Also Im looking for timestamp archiving. ie

archive-dir/2008/11/16/zipfilebypreference.zip

then the next day call it again and it creates another folder. Im sure there is something out there on the internet, who knows?


Solution

  • You have either the:

     

    import  javax.servlet.http.HttpServlet
    
    import  cStringIO
    import  gzip
    import  string
    
    def compressBuf(buf):
        zbuf = cStringIO.StringIO()
        zfile = gzip.GzipFile(mode = 'wb',  fileobj = zbuf, compresslevel = 6)
        zfile.write(buf)
        zfile.close()
        return zbuf.getvalue()
    
    • or the direct used of java.util.zip as illustrated here, for one file, or for a all directory content.