Ziping and unziping files in a directory Please help

I have a program to zip files in a directory and create a .zip file.
But am not able to unzip the file back to the orginal files. This file can be unziped using any unzip tool. But i want to unzip it using java itself
thanks
the code is as follows ......
import java.util.zip.*;
import java.io.*;
public class Zipper
private String dirname;
public void compress_file(String input_dirname,String outfilename)
     //getting all the file names
     this.dirname=input_dirname;
     File f1=new File(dirname);
     String s[]=f1.list();
     try
          byte[] buf = new byte[4096]; //read buffer
          int retval; //return value
          FileOutputStream os = new FileOutputStream(outfilename);
          ZipOutputStream zos = new ZipOutputStream(os);
          FileInputStream is= new FileInputStream("File1");
          for(int i =0;i<s.length;i++)
               System.out.println(s);
               is = new FileInputStream("./conf/"+s[i]);
               zos.putNextEntry(new ZipEntry("./conf/"+s[i]));
               do
                    //read file in from input stream
                    retval = is.read(buf, 0, 4096);
                    //-1 indicates end of file
                    if (retval != -1)
                    //write buffer to output stream
                         zos.write(buf, 0, retval);
               }while (retval != -1);
          //close this ZipEntry
          zos.closeEntry();
          //close input stream
          is.close();
          //close output stream
          zos.close();
     catch(Exception e)
          System.out.println("Exception occurred: " + e);
public static void main(String[] argv)
     Zipper zp= new Zipper();
     zp.compress_file("./conf/","sample.zip");

I'm kinda unclear about what problem you are having, but try this link
http://developer.java.sun.com/developer/technicalArticles/Programming/PerfTuning/#Compression

Similar Messages

  • Unable to burn DVDs because I renamed the drive the project and burn files are on. Please help.

    I am unable to burn DVDs because, not thinking, I renamed the external drive the project is on. How do I fix the problem in DVD Studio Pro 4? I changed the name back on the drive, the files show as linked, but it won't burn. I've tried to refresh the assets, didn't help. Relink is not available to try. I tried to go to file/advanced burn & build, but it was not available either. I'm new to all this so am very afraid to trash the preferences, not knowing if I'm going to do other harm.
    Thanks,
    Trish C

    Reimport the files and drop them into the project.
    Your links should work.
    x

  • I have QuickTime Player 7.6.8, I cannot update or remove it b/c I am missing QuickTime.msi file. It is gone and I need it back. Please help.

    I have QuickTime Player 7.6.8, I cannot update or remove it b/c I am missing QuickTime.msi file. It is gone and I need it back. Please help.

    Unfortunately, this sort of trouble has gotten more complicated to deal with ever since Microsoft pulled the Windows Installer CleanUp utility from their Download Center on June 25. First we have to find a copy of the utility.
    Let's try Googling. (Best not to use Bing, I think.) Look for a working download site for at least version 3.0 of the Windows Installer CleanUp utility. After downloading the utility installer file (msicuu2.exe), scan the file for malware, just in case. (I use the free version of Malwarebytes AntiMalware to do single-file scans for that.)
    If the file is clean, to install the utility, doubleclick the msicuu2.exe file you've downloaded.
    Now run the utility ("Start > All Programs > Windows Install Clean Up"). In the list of programs that appears in CleanUp, select any QuickTime entries and click "Remove".
    Quit out of CleanUp, restart the PC and try installing iTunes again. Does the install go through properly now?
    (If you do find a clean download site for the correct version of CleanUp, please don't tell me where it is. Without wishing to sound paranoid (although I grant it does sound paranoid), there is a non-zero chance that posting links to download locations for the utility here at Discussions leads to that download location being shut down.)

  • We're sorry, but this file is not a valid filetype. GIF, JPEG and PDF files are accepted. Please try again. this is the message its shows when i upload proper format. i do not whom i should ..........

    We're sorry, but this file is not a valid filetype. GIF, JPEG and PDF files are accepted. Please try again.
    We're sorry, but this file is not a valid filetype. GIF, JPEG and PDF files are accepted. Please try again.
    We're sorry, but this file is not a valid filetype. GIF, JPEG and PDF files are accepted. Please try again.
    We're sorry, but this file is not a valid filetype. GIF, JPEG and PDF files are accepted. Please try again.
    We're sorry, but this file is not a valid filetype. GIF, JPEG and PDF files are accepted. Please try again.
    We're sorry, but this file is not a valid filetype. GIF, JPEG and PDF files are accepted. Please try again.
    We're sorry, but this file is not a valid filetype. GIF, JPEG and PDF files are accepted. Please try again.We're sorry, but this file is not a valid filetype. GIF, JPEG and PDF files are accepted. Please try again.

    I got uploaded after many ways. Just logged in windows PC and opened Internet explorer and uploaded it worked.

  • I can not attach any files to email or Facebook. When I go to "browse" the window comes up and disappears immediately. I updated browser and Adobe Flash. Restarted computer and zapped pram. any ideas? Please help!

    I can not attach any files to email or Facebook. When I go to "browse" the window comes up and disappears immediately. I updated browser and Adobe Flash. Restarted computer and zapped pram. any ideas? Please help!

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. For instructions, launch the System Preferences application, select Help from the menu bar, and enter “Set up a guest account” (without the quotes) in the search box. Don't use the Safari-only Guest login created by Find My Mac.
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem(s)?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault in Mac OS X 10.7 or later, then you can’t enable the Guest account. The Guest login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows:
    Be sure your Mac is shut down.
    Press the power button.
    Immediately after you hear the startup tone, hold the Shift key. The Shift key should be held as soon as possible after the startup tone, but not before the tone.
    Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    *Note: If FileVault is enabled under Mac OS X 10.7 or later, or if a firmware password is set, you can’t boot in safe mode.
    Test while in safe mode. Same problem(s)?
    After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2.

  • Zip and Unzip files in PlayBook

    Hello all,
    Just a heads up, File Browser for PlayBook will shortly be getting an update that will allow the users to zip and unzip files. Network browsing is planned for the update after this one (free upgrade ofcourse). 
    Here is a link to the app: File Browser
    My apps: Offline Viewer and FlashLight

    that'd be great, I hope that the wait is worthy!

  • My iTunes won't even load anymore, when I click the icon, it looks like it will open and then it doesn't. Please Help!

    iTunes will not open at all. It looks like it will and then it doesn't (the windows loading symbol appears and then it disappears). I even tried uninstalling iTunes and downloading it again and installing it, nothing works! Please Help!

    1. First check if this file APSDaemon.exe is the problem here.
    Close your iTunes.
    Press Ctrl-Alt-Del key and choose Task Manager. In the "Processes" Tab, select the file APSDaemon.exe and click End Prosses button, then close the task manager window.
    Now open itunes and see if it is working?
    If that works, to prevent having to do the same process everytime you restart Windows, go to. START button, type in
    MSCONFIG
    Hit ENTER
    Click STARTUP Tab, Uncheck "Apple Push", click OK.
    Restart Windows.
    2. If that fails, refer to following article to remove SC Info.lib file:
    http://support.apple.com/kb/TS2363
    3.  If that fails, repair or reinstall your Quicktime.  START / CONTROL PANEL / PROGRAMS N FEATURES / hightlight QUICKTIME and click REAPIR.

  • Why is my iPod Touch's memory 0 when i only have 249 mb of photos and camera and 23l mb of Music? Please help this is a big issue! what do i do? ps i dont want to loose 2 of my apps!!

    I have a 8GB Ipod Touch and i know its not a lot, but in the beginning it was working fine. For some time now it wont let me excede even 1GB of memory. i have no games, no apps, not many contacts, hardly anything! only 249 mb of photos and camera and 23l mb of Music. i have backed it up and restarted it and everything and i am getting annoyed! please help me!! i cant live without my ipod!!! This is urgent!
    P.S: i have 2 apps on my ipod that i would not like to loose! IF theres anyway to save them in the process of fixing my ipod that will be great!
    Thank you!

    An "other" that large usually indicates that the "other" includes corrupted files.  Usually restoring from backup eliminated the corrupted files. However, sometimes restoring to factory settings/new iPod is required.
    To restore from backup see:
    iOS: How to back up
    To restore to factory settings/new iPod see:
    iTunes: Backing up, updating, and restoring iOS software

  • Created PDF form in Acrobat XI Pro, but HELP fields disappear when I save FCDT file to PDF. Please help. Thanks!

    Created PDF form in Acrobat XI Pro, but HELP fields disappear when I save FCDT file to PDF. Please help. Thanks!

    I am not aware of a field type "Help" within a PDF form. I do not see it as a form field that can be added in the form edit mode.
    Forms Central forms do not support all the features of Acrobat forms.
    Are you talking about the "Tool Tips" or a hidden field that only shows when one enters a field and is hidden upon exiting the field.

  • It only uses 32bit, and my computer needs 64bit.   Please help.

    I am a non profit.  I ordered Photo shop Elements12 for PC  for my office.  It is a download only.  It doesn't dowload on my computer.  It only uses 32bit, and my computer needs 64bit.   Please help. The Adobe photoshop elements 12 is useless to me.  I can't seem to get anyone at Techsoup to help and trying to get Adobe to help is runaround.  What should I do to get it to run on my computer.  Please someone in the forum let me know how switch out the download for the correct one.

    64-bit windows can run 32-bit applications just fine and always has.  They are just limited to a small amount of memory.   If something isn’t working it’s likely another problem like an incomplete download or trying to install the Mac version on a PC or something like that.
    You can try downloading and installing from the PSE12 link, here, to see if it works any better:
    http://www.adobe.com/downloads/other-downloads.html
    If you can’t get things to work, then please post a screenshot of the error and a description of what you’re trying to do that lead to the error.
    Also the term “downloading” refers to transferring a file from a remote server, across the internet, to your local computer.   The term “install” means running the program that was downloaded on your local computer to put the working program on your computer that you can run.
    It would be helpful to know if your saying that the actual transfer across the internet part isn’t working, or if that part seemed to work, but when you run that installer program you’re seeing an error.

  • HT1553 Hi, I'm stuck at step 9. I don't see my external harddrive when I want to save the DMG backup file. Can you please help me with this? I'm desperate to make this backup! Big thanx in advance!

    Hi, I'm stuck at step 9. I don't see my external harddrive when I want to save the DMG backup file. Can you please help me with this? I'm desperate to make this backup! Big thanx in advance!
    http://support.apple.com/kb/HT1553

    Repair permissions and restart your computer.  If this does not work, zap the pram.  You should now see your external hard drive. 

  • My keynote seems to be misbehaving. Me, a teacher was preparing a ppt on keynote.all of a sudden, the navigator column to my left goes black and nothing seems to move. Please help! Only 12 hours before I take class.

    My keynote seems to be misbehaving. Me, a teacher was preparing a ppt on keynote.all of a sudden, the navigator column to my left goes black and nothing seems to move. Please help! Only 12 hours before I take class.

    Hi KRKabutoZero,
    Welcome to Apple Discussions
    You may want to look at Knowledge Base Document #58042 on A flashing question mark appears when you start your Mac.
    Do you have access to another Mac? You may want to backing up your files via Target Disk Mode (TDM) as well as running some utilities (Knowledge Base Document #58583 on How to use FireWire target disk mode.
    You may want to invest in a utility like DiskWarrior from Alsoft. It is great for troubleshooting drive malfunctions.
    As said before, you may also want to bring your iBook to your local Apple Store/Reseller.
    Jon
    Mac Mini 1.42Ghz, iPod (All), Airport (Graphite & Express), G4 1.33Ghz iBook, G4 iMac 1Ghz, G3 500Mhz, iBook iMac 233Mhz, eMate, Power Mac 5400 LC, PowerBook 540c, Macintosh 128K, Apple //e, Apple //, and some more...  Mac OS X (10.4.5) Moto Razr, iLife '06, SmartDisk 160Gb, Apple BT Mouse, Sight..

  • Hello i am rajesh i am having problem while conveting other files into pdf format please help me

    i am rajesh i am having problem while converting other files into acrobat format please help me

    Hello Rajesh,
    I'm sorry to hear you're having trouble. Are you using Acrobat.com to convert your files to PDF? Please let me know where you are having trouble and I will do my best to help you convert your files. For your reference, here is a list of filetypes that can be converted to PDF online with Acrobat.com:
    http://kb2.adobe.com/cps/524/cpsid_52456.html#Create%20PDF
    Best,
    Rebecca

  • I have bought the whole CC and it says my trial has expired. But when i go to license the software, it asks for a serial number and i dont have one. Please help.

    I have bought the whole CC and it says my trial has expired. But when i go to license the software, it asks for a serial number and i dont have one. Please help.

    Sign out from Creative Cloud and sign in again using email ID using which you had purcahsed subscription:
    https://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html
    Then launch CC apps which is asking for serial number and check.
    Still asks for serial number check the hosts file for Adobe entries , if present remove it and try to activate.
    1) Right click on the Finder icon on dock and select "Go-To Folder" option.
    2) You will get a text box, type-in below mentioned command and then hit 'Return' key.
    /etc
    3) It will open the etc folder, please look for file named "hosts" and copy the same to Desktop screen.it
    4)Double click on Hosts file , it will open it with TextEdit, If present Delete Adobe entries present inside Hosts file like 127.0.0.1 activate.adobe.com.......etc
    5)Copy and paste the Hosts file back to "Etc" folder.
    When asked Authenticate with your Mac password.
    Make sure to select "Replace" option when prompted.
    Then launch CC apps which is asking for serial number and check.

  • I am trying to stream music from my iMac using iTunes music files to my Cocktail Audio X10 music streamer. I have allowed my files to be shared the X10 sees the files but when I try to accsess them it gives me the message files not mounted. Please help?

    I am trying to stream music from my iMac using iTunes music files to my Cocktail Audio X10 music streamer. I have allowed my files to be shared the X10 sees the files but when I try to accsess them it gives me the message files not mounted. Please help?

    No, I have the music I want to move from the laptop to the phone selected. Then I go under file, devices, and try to click sync but it is not available to click.

Maybe you are looking for