Unzipping Files in the wrong folder

Hi
I am trying to unzip files. It works fine except that it unzips the files at the root. So i have tried specifying the path for making the directory (in which the unzipped files are stored). But that doesnt seem to work. Now i am unable to find the unzipped files. CAN ANYONE HELP PLEASE
public static void unzipFile(String zFile)
        Enumeration entries;
        ZipFile zipFile;
       try {
            zipFile = new ZipFile(zFile);
            File file = new File(zipFile.getName());
            String fname = file.getName();
           String substr1 = fname.substring(0, fname.indexOf("."));
            String filepath = "/data/psawant/temp";
            File dir = new File(filepath, substr1);
            try {
                    dir.mkdir();
            catch (Exception fe)
                  System.err.println("Unhandled exception:");
                    fe.printStackTrace();
                    return;
            entries = zipFile.entries();
            while(entries.hasMoreElements()) {
                ZipEntry entry = (ZipEntry)entries.nextElement();
                if(entry.isDirectory())
                     // Assume directories are stored parents first then children.
                    System.err.println("Extracting directory: " + entry.getName());
                                      (new File(entry.getName())).mkdir();
                    continue;
                } //end of if
                System.err.println("Extracting file: " + entry.getName());
                copyInputStream(zipFile.getInputStream(entry),
                    new BufferedOutputStream(new FileOutputStream(entry.getName())));
             } //end of while
            zipFile.close();
               } catch (IOException ioe)  {                 }
         } //end of unzip function
public static final void copyInputStream(InputStream in, OutputStream out)
    throws IOException
        byte[] buffer = new byte[1024];
        int len;
        while((len = in.read(buffer)) >= 0)
        out.write(buffer, 0, len);
        in.close();
        out.close();
Any help is apprciated
Thanx

Sorry I got it this time. I had overlooked the new File. I added that & it works fine but there seems to be some problem
If the folder has another folder inside . it doesnt show that one. or rather just unzips one folder & no folders inside it. But i guess i can check for that
Thanx for u r help
Have a nice day

Similar Messages

  • My ISP is telling me that iWeb is putting my files in the wrong folder?

    First time trying to publish a website! I am trying to upload my iWeb site files via FTP from a folder that was created by iWeb. My ISP is telling me that the files are being uploaded, but to a sun folder that is not the root directory. They have pushed me back to Apple to resolve. Any help would be apprecited.

    Hello,
    I not sure I understand your problem.
    Are you using the "Publish to a Folder…" command to publish into a site that you connected to with the Finder opening a FTP site?
    I assume the server in question is a Sun server.
    Until I get the answer to my question, let me point out a one thing that could be your problem.
    When iWeb publishes a site, it places into a folder (directory) named to match the name of the web site in iWeb. I referring to the first name in the left column. It defaults to "Site". But, iWeb does put an index.html file in the same folder, which should point web browsers directly into your web site.
    You can remove the contents of the folder and pull it up to the same level with any problem. So, everything in the "Site" folder would be placed at the same level as the "Site" folder.
    By the way, there is a reason for iWeb publishing into a subfolder, because can have multiple web sites in one file. Each site has its own folder.

  • Problem with my program looking for the settings file in the wrong folder

    I have been writing a simple FTP file uploader, what I want to do is be able to select the files I want to upload in windows explorer and then right click and click the menu item and it launches the program and passes the files paths that I have selected to it.
    So I use this in the windows registry "C:\Program Files\Java\jre1.6.0_03\bin\java.exe -jar D:\BenFTP\BenFTP.jar %1"
    It launches fine and has no problem finding the files I want to upload. The problem is that it tries to look for the settings file in the same folder that the file I am try to upload is in. Which it's not suppose to do since the settings file is in the same folder that the .jar is in.
    Edited by: ColNewman on Feb 5, 2008 6:55 PM

    So, you're looking for your settings file in your current working directory. There's no way to set the CWD in your registry entry (is there?) so that isn't a practical thing to do. Presumably you're using a File object or a FileReader or something? Can't do that.
    One alternative is to look for the settings file in the classpath. You can get a URL to a file in the classpath like this:URL settings = this.getClass().getResource("/settings.xml");Or you can get an InputStream to read the file by using the getResourceAsStream method. You would have to make sure that your executable jar file contained a Class-Path entry that specified the right directory, because the directory the jar is contained in isn't automatically in an executable jar's classpath.
    Another alternative is to ask the user where the settings file is supposed to be, and put an entry in the Preferences (java.util.prefs) to remember that location.

  • Image Capture saving files to the wrong folder

    This happens pretty consistently. I select the folder I want to download my pictures/movies to and it downloads to one of my previously selected folders. How can I fix this so that it places the files in the folder I specify?

    Hi,
    In the Welcome screen, you can accept the license agreement and can go ahead with the installation. You will be asked for the serial number. If you don't have one, install it as a trial application. By default, it's installed in the Applications folder. However, you can change the installation folder in the third screen, if you have a reason. Please see the screenshot below:
    After installing, you can't move application to a different directory by dragging. You need to uninstall and install it again in the folder of your choice.
    Thanks,
    Sunil

  • The dmg files have downloaded to the wrong folder - not finished with the install process

    The dmg files have downloaded to the wrong folder - I am at the part of the download/install process where the "Welcome" screen appears asking for me to agree to the license agreement.  Somewhere on your site, I read that they should NOT go to the applications folder but to the "Users" folder. Can/should I move/drag the folder with the dmg files into the "Users" folder"? If so, before or after I complete the install? I am running MAC OSX 10.7.4 on a MAC Mini.
    Also, when the trial period is over, I will use the license number for the purchased software disks, should the dmg's/folders then be moved to the application folder or stay in the "users" section? I have Purvhased Adobe Photoshop Elements 10 and Adobe Premiere Elements 10, but somewhere on your site it was suggested to download them instead and use the license code at the appropiate time. If someone can help with these questions, I would appreciate it. Thank you

    Hi,
    In the Welcome screen, you can accept the license agreement and can go ahead with the installation. You will be asked for the serial number. If you don't have one, install it as a trial application. By default, it's installed in the Applications folder. However, you can change the installation folder in the third screen, if you have a reason. Please see the screenshot below:
    After installing, you can't move application to a different directory by dragging. You need to uninstall and install it again in the folder of your choice.
    Thanks,
    Sunil

  • Hello, I am attempting to install Camera raw from a .zip file provided via a link provided by adobe for a Nikon D810. The .zip file unzips fine and I moved the files to the recommended folder. But the operation is failing

    I am attempting to install Camera raw from a .zip file provided via a link provided by adobe for a Nikon D810. The .zip file unzips fine and I moved the files to the recommended folder. But the operation is failing

    Can you describe what “the operation is failing” means?  What is happening and how is it different than what you expect?
    Also, what product are you trying to update manually, and do you have a link to the page of instructions, so we know what your attempting to do?

  • Imported Files going in the wrong folder

    Elements Organizer 10 started misplacing all the Imported Files in the folder above at some point.
    In Folder Location view (under Display) I right click folder B and chose Import to Elements Organizer. Once the Import is finished, all photos but one are under folder A instead... needless to say my catalog now looks very messy because photos show in folders with different names. In Finder they appear in the right place, and even the File Properties in Elements show the correct location. Just not the Folders.
    I have about 20k files imported in my catalogue, this started happening recently and affects only files imported in certain external drives or partitions.
    I tried the repairs, optimizations, reconnects etc. for the catalogue, looked for updates and restarted the software many times now.
    How can I fix this?

    Hi guys,
    Sorry about slow time to reply.
    I'll try to be a bit more specific.
    The problem seems to happen only with a new firewire drive, Lacie Rugged 1gb.
    I have Mac OS X v10.6.8, processor 2.26Ghz, intel core duo, 8Gb 1067 DDR3; Elements Organizer 10.0
    The problem happens regardless of how I import the files, ie in thumbnail or folder view, and my procedures have not changed since using previous drives (right click folder and chose Import to Elements Organizer). If I am in thumbnail view or folder batch view the files are there, however having to browse among Ks of files is not my preference, I like folder view better.
    I think the image below explains it better: the folder selected is called Group Tax team day (bottom left). The  photo at the top is actually from this folder, but the one at the bottom (and all the others then) are from a folder called HK Dez 2012, which is the last that was imported directly below. You can actually see that the path at the top of the image does not match the selected folder on the lower left. And btw, this means that the files at the top folder in the drive cannot be found in folder view, since they have no folder to move to.
    Appreciate any help on this!

  • Recorded audio in the wrong folder

    I recorded my audio in the wrong folder (they are not in the project folder). I copied them over to my project folder but can't figure out how to link my song file/audio regions to the new location. I tried to set this in the Audio Window by resetting "Set Audio Record Path" but it wants me to give it a new file name (creating a whole new document?)
    Can someone help me work this out?

    Brian:
    Try putting the files back in their original folder location, open up the project, and then use the Project -> Consolidate menu option. If I recall correctly it will move everything into a new specified folder (or an existing folder) and re-reference the paths for you.

  • 244 random photos suddenly appeared in the wrong folder

    I recently imported 8 photos into Lightroom 5.7 using the "2015-05-25 Folder Name" naming system, and I saw the 8 imported photos in the folder. No problems. However, after reopening Lightroom, the folder with 8 photos suddenly has 252 photos. There are 244 random photos from various years and various other folders which are also inside of my main "Photo Library Lightroom" folder. I had been assigning "key wordis" to photos last week, but I am not sure how that could have taken 246 random photos and "shoved" them into the wrong folder. Do I have to manually "refile" the "misfiled" photos, or is there a magic button to get Lightroom to fix this?

    ssprengel wrote:
    One thing that could explain at least most of the situation is that you did a synchronize at a top-level folder then had Move as your Import type instead of Add, as well as Don’t Import Suspected Duplicates UNCHECKED, and LR imported and moved all those photos to whatever your current destination was.
    This does sounds like what might have caused the "Move" of 244 random files into the single new folder, but I don't think so.
    If the 244 random files were previously imported into LR they would be not selected when doing a 'Synchronize Folder' operation on a top-level folder. 'Synchronize Folder' searches the selected folder and subfolders if 'Show Photos in Subfolders' is checked in the Library menu. Files that reside in the target folders on the HDD that are NOT currently showing inside LR will be imported.
    If the 244 random files were NOT previously imported into LR then they would be imported if the 'Synchronize Folder' was performed on the top-level containing folder. Unfortunately I can't duplicate this as I only see 'Add' with the other options grayed out when importing files from numerous subfolders with files that are not showing inside LR. Here's what I see with 'Don't Import Suspected Duplicates' checked or NOT checked:
    Even if I select 'All Photos' only the files that are "missing" inside LR are checked for Import. It's impossible to select any other files inside LR or force it to 'Move' the files to a new destination folder.
    Steve, is there some mode or setting I'm missing that would allow selecting 'Move' when doing a 'Synchronize Folder' Import?

  • JWS requests jar files at the wrong place

    Hi all,
    I created JWS project with netbeans, and by deafult, NB places all required jar files in the "lib" folder. NB also created jnlp file with correct paths to required files. It looks like this
    <update check="always" policy="always"/>
    <resources>
         <jar download="eager" href="main.jar" main="true"/>
         <jar download="eager" href="lib/required.jar" main="false"/>
    </resources> Now, when app is started, required.jar is correctly located at lib folder and application works, but from that moment on, JWS makes hundreds of request for "${codebase}/required.jar" (obviously wrong place) and gets 404 responses. It keeps making these requests as long as app is running and this slows down application significantly.
    My temp workaround was to move required.jar to codebase root and problem is gone, but i still find it weird. I guess this may explain some complaints about slow JWS.
    Is this a bug? Am I doing something wrong? Is there anything I can check?
    Thanks!

    dario wrote:
    ..Is there anything I can check?The JNLP file, using JaNeLA. Even the three lines shown appear to include mistakes (probably because Ntebeans wrote it).

  • Unzipping files from a zipped folder

    Hi,
    I need unzip files stored in .zip folder using ABAP. Could you please tell me of a utility/Funtion Module or any other method which exists for the same?
    Thanks a lot
    Shujath

    Hi Mohammed,
    you just have to execute an external program from your ABAP.
    For example, if the ZIP file is in the client computer you have to use the WS_EXECUTE.
    Have fun
    Frédéric

  • Nothing shows up on my Desktop. I can put a file into the Desktop folder but it will not appear on the DTop. The HarDrive is not on the DTop either.

    Nothing appears on my Desktop. The Finder seems to work, so I can place a file into the DTop folder, but nothing appears on the DTop, not even the HarDrive.

    You can temporarily hide the crap on your desktop. Edit the CreateDesktop key in com.apple.finder:
    defaults write com.apple.finder CreateDesktop -bool false && killall Finder
    Then, to get my clutter back:
    defaults write com.apple.finder CreateDesktop -bool true && killall Finder

  • HT2531 Spotlight lists items and shows preview images.  BUT what about showing the location address of an item in my computer. Especially important if I've put the item in the wrong folder and what to locate it without multi-steps. iMac OS 10.5 was more u

    Spotlight lists items and shows preview images.  BUT what about showing the path/location address of an item in my computer.
    Especially important if I've put the item in the wrong folder and what to locate it without multi-steps. iMac OS X 10.5 was more useful.
    Old OSX Spotlight function automatically displayed path/location within the machine:  e.g. desktop/folder/sub-folder/item.
    Can I make Spotlight show the path?

    Press option-command and the path is displayed at the bottom of the little preview window.  Press command-return and the enclosing folder opens. 

  • Mail starting to down load into the wrong folder, Why?

    Why did mail start putting mail in the wrong folder ? How can rules change ? can I down load only the Mail app ?

    Have you compacted your In-box lately?
    Do you get an error message?

  • HT203200 Cannot delete the file from the itunes folder

    I cannont delete the file from the itunes folder because it tells me I need permission to do so.  I am the admin person for the laptop plus I have checked my permissions under the security tab in the files properties.  How do I delete this file to start again?  It downloaded 1.2GB of the file before the error message appeared, so its paid for and all but not looking like I'll get to watch it before the time runs out on the movie being available for me to watch. :-(

    Try deleting the file without iTunes running.
    When you next open iTunes it should then be marked as a missing file and you should be able to delete the entry from iTunes.
    Hope this works
    Regards,
    Colin R.

Maybe you are looking for

  • Financial Reporting Chart Legend

    Hi everyone, I want to create some chart in Financial Reporting Studio. I was wondering if have any idea of how to present the legend of a chart in Financial Reporting in a line instead of a column that it is the default. Thank you in advance

  • Expanding stacks loses files from Lightroom - help!

    I've just discovered the delights of stacking, and have stacked brackets in several folders. The first time I expanded these (via Photo > Stacking > expand all stacks), in order to rename all the files in the folder, it worked fine. However since the

  • Is it possible to highlight a part of a grah in a waveform graph

    I would like to permit a user to select a part of a graph between 2 cursors and then highlight this part. Although I found in an example how to change colors in a waveform chart, I need to do the same in a waveform graph.. Thank you for your help

  • FDM Multiload output file does not have period dimension member

    FDM is cutting the file successfully with multiload but missing period member from the record/row. About import file - location, category, number of periods, load controls and dimensions tags with 12 periods. Single record from import file... Entity,

  • Mac installing flash player, Flash quits unexpectedly when opened after download.

    Can anyone help me with this?  Flash has been in use on my mac for a long time, but when I updated to 11 version it never worked right, and kept using older version to play games etc.. and I updated to flash 12, the flash program quits unexpectedly w