CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2014
    Posts
    15

    ZipEntry to java.io.File

    I have a zip file containing folders which in turn contains xml files I would like to parse. I have the content as ZipEntry objects and my parser takes InputSource objects.

    In the translation i keep messing up and I get the following error message:
    Code:
    Exception in thread "main" java.io.FileNotFoundException: metadata\coreProperties.xml (The system cannot find the file specified)
    	at java.io.FileInputStream.open(Native Method)
    	at java.io.FileInputStream.<init>(Unknown Source)
    	at java.io.FileReader.<init>(Unknown Source)
    	at StealsMain.main(StealsMain.java:90)
    I have tried to locate the problem and it seems to come from the following:

    Code:
    String currentFile = fileName + "/" + g2;
    File curr = new File(currentFile);
    					System.out.println(curr.toString());
    					System.out.println(curr.exists());
    Here fileName is the path to the zip file and g2 is the path inside the zip file.
    the first System.out.println gives the correct location of the file:
    /.../My Documents\FilB.slx\metadata\coreProperties.xml
    But the second claims the file does not exist, which is why I cant pass it to the parser (after making it an inputsource).

    How can I go from zipEntry to file object?

  2. #2
    Join Date
    Jul 2005
    Location
    Currently in Mexico City
    Posts
    568

    Re: ZipEntry to java.io.File

    The new File(currentFile) part just creates a new file object in memory, thus the System.out.println(curr.toString()); prints its supposed location (this does not mean that the file exists physically). The fact that System.out.println(curr.exists()); returns false means that the file does not exist. This proves that the file path you provide for the xmls is incorrect. I'd recommend verifying the input file path.
    Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?

    I had a nightmare last night. I was dreaming that I’m 64-bit and my blanket is 32-bit and I couldn’t cover myself with it, so I’ve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from: bash.org.ru)

    //always looking for job opportunities in AU/NZ/US/CA/Europe :P
    willCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL"));

    USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!

  3. #3
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: ZipEntry to java.io.File

    Norm

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured