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!

Similar Messages

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

  • How to open projects within a zip file?

    Is there any way to use the open project feature to open projects within a zip file loaded onto a LMS?  I have several files loaded in a zip file and I would like to navigate to each one within the zip file itself.  The problem that I see is that it does not know where to look.  Within the zip file, there is a main menu file that is used to branch out to another project file and then the user will go back to the main file to navigate to another.  I know this seems complicated, but I am being asked to see if this is possible.

    A zipped SCORM package is always unzipped on the LMS server after upload.  So you need to look at the file and folder structure of the SCORM after it was unzipped to see how to navigate or link to other elements.
    However, let me just say that what you are trying to do will almost certainly cause you many headaches.  A multi-SCO SCORM package is meant to be comprised of several individual SCO modules that do not usually talk to each other because by definition in the SCORM standard they are supposed to be standalone and not require anything else to play.
    Additionally, a multi-SCO package uploaded to an LMS is intended to allow the LMS to control navigation to individual SCO modules via the TOC links that the LMS creates in its own SCORM player.  Once you start over riding these links and opening up individual SCOs without using the TOC links you run the risk of confusing the LMS as to which SCO is actually playing.  The SCORM API only wants to deal with one SCO at a time.

  • How to read and write a string into a txt.file

    Hi, I am now using BEA Workshop for Weblogic Platform version10. I am using J2EE is my programming language. The problem I encounter is as the above title; how to read and write a string into a txt.file with a specific root directory? Do you have any sample codes to reference?
    I hope someone can answer my question as soon as possible
    Thank you very much.

    Accessing the file system directly from a web app is a bad idea for several reasons. See http://weblogs.java.net/blog/simongbrown/archive/2003/10/file_access_in.html for a great discussion of the topic.
    On Weblogic there seems to be two ways to access files. First, use a File T3 connector from the console. Second, use java.net.URL with the file: protocol. The T3File object has been deprecated and suggests:
    Deprecated in WebLogic Server 6.1. Use java.net.URL.openConnection() instead.
    Edited by: m0smith on Mar 12, 2008 5:18 PM

  • How to read a tab seperated data from a text file using utl_file

    Hi,
    How to read a tab seperated data from a text file using utl_file...
    I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....
    Thanks in advance...
    Naveen

    Naveen Nishad wrote:
    How to read a tab seperated data from a text file using utl_file...
    I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....If it's a text file then UTL_FILE will only allow you to read it a line at a time. It is then up to you to split that string up (search for split string on this forum for methods) into it's individual components.
    If the text file contains a standard structure on each line, i.e. it is a fixed delimited structure, then you could use external tables to read the data instead.

  • How to refer an xml file within a xml file?

    Hi
    I would like to refer a xml file within a xml file from where i would like to extracts some elements & attributes.
    Plz, suggest me hot to do.
    Thank you.

    You mean you want to link the file thru some resource pointer and then make the external file availabe for parsing and other processing operations?

  • How to read the date and time information of a file by labview

    how to read the date and time information of a file by labview? for example, created time and modified time.
    Solved!
    Go to Solution.

    if you need to know the last modification date of file:-
    "Functions->File I/O->Advanced File Functions->File/Directory Info.vi"
    This vi returns the value of file's last modification date. This is returned as U32 number. To see it in MM/DD/YY format you must create the indicator, right-click on it and select "Format & Precision" item from drop-down menu. Then select "Time and Date" format there.
    Thanks as kudos only

  • How/where can you change the delimiters within the output file -Urgent Pls!

    Hello Experts,
    When Exporting data through EAS, how/where can you change the delimiters within the output file (ie. space delimited vs tab delimited vs custom)
    Thanks in advance.
    Regards,
    Sonu

    This is where I will be shot down in flames but at least in 7.x I am unaware of any configuration option that allows you to export in anything other than space delimited.
    I guess you could write a shell/perl script that could change this outside of Essbase
    Edited by: DrFosterMan on Jan 16, 2009 12:54 PM

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

  • Can't print a PDF file that is within a ZIP file.

    Can’t print a PDF file that is within a ZIP file.  Get message “Windows cannot complete the transaction.  The destination file could not be created.”  If I save the file and extract the pdf it works.  I didn't have to go through this hastle before.  If I retry many times it will often work.

    ZIP files can be handled in many different ways.  If you have a program like WinZip or 7-Zip installed, they will handle it.
    If not, Windows will handle it.  The message you quote indicates that your situation is handled by Windows, which seems to have a problem with it.  Could be caused by recent Windows updates.
    Definitely not an Adobe Reader problem.

  • How can I install attachments for SAP notes with zip-files ???

    How can I install attachments for SAP notes with zip-files ???

    Can you elaborate on your question? How exactly is your question related to SAP NetWeaver Portal: Application Integration? If you are really asking how to install attachments contained in SAP notes, there is no automatic/general way and you should ask your question in the Software Support and Maintenance space to begin with. What SAP note(s) are you looking at installing?

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

  • 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

  • Problem opening a zip file within a jar file

    Hi,
    I have a jar file in a tomcat web server. The jar file includes a zip file which I've been trying to open with the following sentences:
    SpellDictionary dict = null;
    File f = new File(getClass().getResource*("us_US.zip"*).getFile());
    dict = new OpenOfficeSpellDictionary( new ZipFile( f ) );
    I'm getting this exception:
    2007-09-13 15:31:38 java.util.zip.ZipException: No such file or directory
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:203)
    at java.util.zip.ZipFile.<init>(ZipFile.java:84)
    at com.iir.newsAdministration.textEditor.TextEditorSpellChecker.<init>(TextEditorSpellChecker.java:62)
    If I run the application with the builded classes instead of the jar file, it works fine.
    Any ideas about how can I make it work with the jar file?
    Thanks in advance
    Natalie

    File f = new File(getClass().getResource*("us_US.zip"*).getFile());
    This is not going to work.
    What you need to do is create a Jar/ZipFile from your jar, then extract the ZipFile, put that in a temporary location, then open that with another ZipFile object

  • How to find if the uloaded file is a zip file

    Hello everyone,
        I am currently implementing a filter in my code where I put a restriction that allows only a certain type of files to be accepted. One of them is the zip file type.
    However, when I tried to read the mimetype of this zip file using the folloing API :
    IWDResource.getResourceType().getHtmlMime(),
    I get "application/octet-stream" which is the mime type of any binary file, and not "application/zip" which is the usual zip file mimetype.
    Therefore it is difficult to identify whether the uploaded file is a zip file which we can operate on accordingly.
    I need to know whether there is some way I can acheive this?

    Hi Dhruwat
    there is a java-api called [truezip|https://truezip.dev.java.net]
    in which you will find the following class ZipDetector, and the method "isZipFile".
    [https://truezip.dev.java.net/javadoc-5/de/schlichtherle/io/ZipDetector.html#isZipFile(java.lang.String)]
    Or something other but i don't know if you can find out that.
    Every (regular) zip has the encoding "CP437". Maybe you can
    check the outputstreams-encoding..?
    Regards

Maybe you are looking for

  • How do I close a web site and get back to the home page?

    When I click the close button on a web page I end up at the desktop with no visible means of using other sites. When I click on the fire fox logo again I am told that I am already connected. When I use the back button instead of the close button to g

  • Problem in j1inmis

    my document has not been updated through T.Code J1INMIS at the time of internal challan creation in both ( 194C & WCT) what can be the problem

  • LOV in oracle express

    Hi! I want do define a lov like this: select category, category from demo_product_info the problem ist that an error appaers that i am not allowed to use the same column-name for display and return-value?! thx!

  • IPhoto 9.2.1 not importing photos from iPhone 4S

    When I plug in my 4S, or an alternate 4S, iphoto will recognize that there are photos that need to be imported, however when I click import all, it inicates that it cannot read any of the files, and does not import any of the photos or videos. I have

  • Hide trigger in Tab Panel, but keep target active?

    I'm working with having compositions inside a tabbed panel. I know there is a way to have the triggers hidden, and then when clicked or rolled over activate a target. But is there a way to keep a target active (shown) while the trigger is 'hidden' in