Creating a File object out of the contents of jar/zip file

Discussion in 'Java' started by kotauk, Apr 6, 2006.

  1. kotauk

    kotauk Guest

    Hi,
    How to create a File object of .java file contained in jar/zip file.
    For eample i have a zip like test.zip
    It has a file mypack.today.MyProg.java

    Give the jar file how to create File object of the MyProg.java.

    Any pointers would be great help

    thanxs
    kota
     
    kotauk, Apr 6, 2006
    #1
    1. Advertisements

  2. jar -x filename jarname > retrieved_file
     
    Fred Kleinschmidt, Apr 6, 2006
    #2
    1. Advertisements

  3. kotauk

    kotauk Guest

    Hi Fred,
    I want to create java.io.File object programatically

    thanks
    kota
     
    kotauk, Apr 6, 2006
    #3
  4. kotauk

    kotauk Guest

    Hi Fred,
    I want to create java.io.File object programatically while reading
    the jar using java.util.jar.JarFile


    thanks
    kota
     
    kotauk, Apr 6, 2006
    #4
  5. Read <http://java.sun.com/j2se/1.4.2/docs/api/java/util/jar/JarFile.html>.
    There is all you need to get an InputStream for reading a zip-entry of the
    the jar. Open a FileOutputStream for the destination file. Then copy all
    bytes from the InputStream to the FileOutputStream.
     
    Thomas Fritsch, Apr 6, 2006
    #5
  6. kotauk

    Roedy Green Guest

    Roedy Green, Apr 6, 2006
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.