Help with util.zip up files... does not work

I am writing a program so my mum can zip up new photos she takes and then send them to me. The program creates a html file for the webpage plus a smaller version of her original photo and places them all in a 1 folder with a new name. Al this part works... I want to afterwards place my files in a zipped up folder that she can e-mail me with her normal client. How... I picked up this code on the net and have changed it to incoporate my parameters. The files which are created ..paths are (String in an String[]) I then send to my zipping method.
The zip file is created but does not work when I try to extract from it ??? I also know that the String [] works becuse I have made a loop to check its properties at each index.
what am I doing wrong?
This is a modified code I found on the internet but with no author??
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.*;
public class Test{
    private File zipDir;
    private String[] filename;
    public Test(String[] recivedFilename){
        filename = recivedFilename;
        try {
            ZipOutputStream zos = new
                    ZipOutputStream(new FileOutputStream("c:\\curDir.zip"));
            from,
            zipDir("c:\\batviapictures\\", zos);
            zos.close();
        } catch(Exception e) {
            //handle exception
    public void zipDir(String dir2zip, ZipOutputStream zos) {
        try {File
            zipDir = new File(dir2zip);
            String[] dirList = filename;
            byte[] readBuffer = new byte[2156];
            int bytesIn = 0;
            //loop through dirList, and zip the files
            for(int i=0; i<dirList.length; i++) {
                File f = new File(zipDir, dirList);
if(f.isDirectory()) {
String filePath = f.getPath();
zipDir(filePath, zos);
continue;
FileInputStream fis = new FileInputStream(f);
ZipEntry anEntry = new ZipEntry(f.getPath());
zos.putNextEntry(anEntry);
while((bytesIn = fis.read(readBuffer)) != -1) {
zos.write(readBuffer, 0, bytesIn);
fis.close();
catch(Exception e) {

I make no guarantees that this will completely solve all your problems, but I just know these calls are needed but missing from your OP:
try {
    ZipOutputStream zos = new
                    ZipOutputStream(new FileOutputStream("c:\\curDir.zip"));
                    from,
                    zipDir("c:\\batviapictures\\", zos);
    zos.flush(); // ADD THIS after all files have been written to the zos
    zos.close();
} catch(Exception e) {
    //handle exception
}And
while((bytesIn = fis.read(readBuffer)) != -1) {
    zos.write(readBuffer, 0, bytesIn);
zos.closeEntry(); // ADD THIS after each file is written to the zos
fis.close();

Similar Messages

  • The message function on my Ipad just quit working.  I was using it while in Mexico and it just quit.  I have come home and synced my Ipad with Itunes and function still does not work.  How do I get this function to work again?

    The message function on my Ipad just quit working.  I was using it while in Mexico and it just quit.  I have come home and synced my Ipad with Itunes and function still does not work.  How do I get this function to work again?

    When I use find file http://www.macupdate.com/app/mac/30073/find-file (which does tend to find files that "Finder" can't), it's not coming up with any other itunes library files that have been modified in the past week, which I know it would have been - unfortunately, I don't have a very recent backup of the hard drive.  It would be a few months old so it wouldn't have the complete library on it....any ideas?  I'm wondering if restarting the computer might help but have been afraid to do so in case it would make it harder to recover anything...I was looking at this thread https://discussions.apple.com/thread/4211589?start=0&tstart=0 in the hopes that it might have a helpful suggestion but it's definitely a different scenario.

  • When streaming a movie with the new Apple TV, and using a DSL Internet connection, all audio sound works, e.g., the music track, but the audio track with the actor's voices, does not work. What can I do?

    When streaming a movie with the new Apple TV, and using a DSL Internet connection, all audio sound works, e.g., the music track, but the audio track with the actor's voices, does not work. What can I do?

    Hi Brian,
    Thanks restoring and restarting didn't fix my problem - i have started it fresh and still it doesn't work. Basically I press ONCE on the remote, after the machine has not had any commands for 10 minutes, and the cursor skips from one end of the menu to the other - so I can't choose network or update software etc - I sometimes manage to stop it randomly in the middle of the menu if I press on a command in the middle of the cursor skipping all the menu steps...not sure what the problem is but I have basically not used my brand new apple tv since I bought it for that reason! I should call Apple support I suppose! grrrr hate wasting time with stuff like this!
    Thanks for your help though!
    Pernille

  • I look for integrated in the legend bloc of diaporama, a widget such as "Accordion" for, with a click, or passing with mouse, open a new legend for each photo. I tried with "Accordion" of Muse, it does not work. I tried copy/paste, mais no result. The wid

    Question.
    I look for integrated in the legend bloc of diaporama, a widget such as "Accordion" for, with a click, or passing with mouse, open a new legend for each photo. I tried with "Accordion" of Muse, it does not work. I tried copy/paste, mais no result. The widget disappear in bloc legend. disparaître. Have you one solution?
    Thank you,
    Loïc

    Accordion or Tabbed panel should to it, with click and open container.
    Please provide site url where this does not work, also if you can provide an example where we can see the exact action then it would help us.
    Thanks,
    Sanjit

  • F4 help on Parameter for ddic domain does not work

    Hello,
    I try:
    Parameters:  pa_waers TYPE WAERS.
    WAERS is a ddic data element for currencies and also a  domain with this name exists. The domain WAERS has a check table TCURC.
    When I press F4 for my field PA_WAERS in the Selection Screen, I assume a value help from the check table TCURC.
    I activated and re-generated my coding (as mentioned in the ABAP-Keyword help for "PARAMETERS") but it still does not work.
    Does anybody has a clue why this does this not work.
    The same thing is for a parameter:
    Parameters ..... type CTU_MODE.
    Domain CTU_MODE has value Fields (A, E, B) but also here on my program no F4 help occurs.
    Thanks in advance
    Stefan Berger

    A value table is assigned to a domain.  It becomes a check table when a foreign key relationship is established for a field in a table.  The field uses the data element and the data element uses the domain.
    For example, if you try:
    PARAMETERS: PA_WAERS TYPE EKKO-WAERS.
    You will get the F4 help you are looking for.  If you use tran SE11 and view EKKO, find field WAERS, use tab Entry Help/check and you will see that table TCURC has been established as a check table.  You can use the foreign key button to see the relationship that has been established between EKKO and TCURC.
    Also, domains cannot be used to type a field.  Your reference to CTU_MODE must be referring to a Data Element.  I tried this in a 4.7 system and the F4 works for me.  What version are you using?

  • HT4623 i updated my ipad with ios7 but the keyboard does not work as it should hit the letters it is slow and does not click as it should

    updated my ipad with ios7 but the keyboard does not work its slow when i hit the letters does not click did not do this until i updated anyone can help me on this to fix it

    Settings>General>Reset>Reset All Settings

  • Publishing a flash with AS3.0 on website does not work

    Okay, I'm finally at the end of my flash card. Here's the whole code.
    //import classes
    import com.greensock.TweenLite;
    import com.greensock.easing.*;
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    //end of importing
    //start of sound section is for sound
    var cssLoader:URLLoader;
    var css:StyleSheet;
    var soundReq:URLRequest=new URLRequest("audioFiles/PaukenBrumfiel_AngelsOnHigh.mp3");
    var sound:Sound = new Sound();
    sound.load(soundReq);
    sound.addEventListener(Event.COMPLETE, onComplete);
    //end of sound section
    //Loading external texts
    var weiss:Font = new Weiss();
    var weissBold:Font = new WeissBolder18();
    var weissBolder:Font = new WeissBolder();
    var slideXTween:Tween;
    var txtAlphaTween:Tween;
    var txtNextText:Tween;
    var txtContainer:Sprite;
    var txtField:TextField = new TextField();
    var myTxtField:TextField = new TextField();
    var txtFldwebImages:TextField = new TextField();
    var textRequest:URLRequest=new URLRequest("happyHoliday.txt");
    var textLoad:URLLoader = new URLLoader();
    var txtFormat:TextFormat = new TextFormat();
    var myLinkFormat:TextFormat = new TextFormat();
    var strLink:String;
    var numXPos:Number;
    var numYPos:Number;
    //end of loading external texts
    function onComplete(event:Event):void {
        sound.play();
    function textReady(event:Event):void {
        //txtFormat.font= weiss.fontName;
        txtFormat.color=0x000066;
        txtFormat.size=24;
        //txtField.x = stage.stageWidth;
        //txtField.width = 800;
        txtField.autoSize=TextFieldAutoSize.LEFT;
        //txtField.height = txtField.autoSize
        txtField.wordWrap=false;
        txtField.text=event.target.data;
        txtField.setTextFormat(txtFormat);
        //txtField.y = 350;
        txtField.embedFonts=true;
    textLoad.load(textRequest);
    txtFormat.font= weiss.fontName;
    textLoad.addEventListener(Event.COMPLETE, textReady);
    txtField.x=stage.stageWidth;
    addChild(txtField);
    txtField.y=350;
    TweenLite.to(txtField, 40, {x:-stage.stageWidth*2.25, ease:Linear.easeNone, delay:0.5, onComplete:Inspiration});
    function Inspiration():void {
        txtFormat.font= weissBolder.fontName;
        textLoad.load(new URLRequest("inspiration.txt"));
        txtField.x=130;
        txtField.y=330;
        txtField.alpha=0;
        TweenLite.to(txtField, 5, {alpha:1, onComplete:GoogleFunc});
    function GoogleFunc():void {
        //create and initialize css
        addChild(myTxtField);
        strLink = "<a href='http://www.google.com/' target='_blank'>Google</a>";
        numXPos = 180;
        numYPos = 370;
        var myCSS:StyleSheet = new StyleSheet();
        myCSS.setStyle("a:link", {color:'#000066',textDecoration:'none'});
        myCSS.setStyle("a:hover", {color:'#FF6600',textDecoration:'underline'});
        txtFormat.font = weissBold.fontName;
        //txtFormat.color=0x000066;
        txtFormat.size=20;
        //txtFormat.bold = true;
        myTxtField.setTextFormat(txtFormat);
        myTxtField.defaultTextFormat=txtFormat;
        myTxtField.styleSheet = myCSS; // Linking CSS to TextField
        myTxtField.htmlText="";
        myTxtField.htmlText=strLink;
        myTxtField.wordWrap=false;
        //myTxtField.embedFonts = true;
        myTxtField.width = strLink.length*2;
        myTxtField.x=numXPos;
        myTxtField.y=numYPos;
        //trace("Third txtField.y: " + txtField.y);
        myTxtField.alpha=0;
        TweenLite.to(myTxtField, 1, {alpha:1, onComplete:webImages});
        //trace("tween done");
    function webImages():void {
        addChild(txtFldwebImages);
        var myCSS:StyleSheet = new StyleSheet();
        myCSS.setStyle("a:link", {fontsize:'20',color:'#000066',textDecoration:'none'});
        myCSS.setStyle("a:hover", {fontsize:'20',color:'#FF6600',textDecoration:'underline'});
        txtFormat.font = weissBold.fontName;
        //txtFormat.color=0x000066;
        txtFormat.size=20;
        //txtFormat.bold = true;
        txtFldwebImages.setTextFormat(txtFormat);
        txtFldwebImages.defaultTextFormat=txtFormat;
        txtFldwebImages.styleSheet = myCSS; // Linking CSS to TextField
        txtFldwebImages.htmlText = "";
        txtFldwebImages.htmlText="<a href='http://www.google.com/webImages/' target='_blank'>Google Images</a>";
        txtFldwebImages.wordWrap=false;
        //myTxtField.embedFonts = true;
        txtFldwebImages.width = 300;
        txtFldwebImages.x=300;
        txtFldwebImages.y=370;
        txtFldwebImages.alpha=0;
        TweenLite.to(txtFldwebImages, 1, {alpha:1});
    //end of loading external texts
    Okay, the problem is when I publish the .swf files and put it in an html or .aspx page, it does not work. The audio is not there and a few others things ar enot working. However, it does work if I click on the.html file that Flash created during the publication.
    Here are the folder structions:
    www.mysite.com/myFlashPage.aspx
    www.mysite.com/flashFileFolder/
    www.mysite.com/flashFileFolder/audioFiles/
    So, the myFlashPage.aspx containsthe myFlash.swf file that is inside the flashFileFolder. For some reason, it does not work. Any suggestion is much appreciated.

    The .html file does work if I publish it into the same folder as I created the Flash project. However, when I publish the
    flash .swf to my web site folder (mapped), it's no longer working. The mapped web site drive structher are as follows:
    D:\Mysite\ contains the .html file
    D:\Mysite\flashFileFolder\ contains the .swf file
    D:\Mysite\flashFileFolder\audioFiles contains the PaukenBrumfiel_AngelsOnHigh.mp3 file
    D:\Mysite\flashFileFolder\greensock-tweening-platform-as3 contains all the tweenlite files
    The .html file does not work either. What else do I need to change?

  • [svn:fx-trunk] 5019: ASDoc updates to indicate that some Halo containers do not work with the Spark equiv (ControlBar does not work with Spark Panel/ AppControlBar does not work with Spark Application), and indicate that Canvas, Box, Tile, Panel have Spa

    Revision: 5019
    Author: [email protected]
    Date: 2009-02-19 13:17:21 -0800 (Thu, 19 Feb 2009)
    Log Message:
    ASDoc updates to indicate that some Halo containers do not work with the Spark equiv (ControlBar does not work with Spark Panel/AppControlBar does not work with Spark Application), and indicate that Canvas, Box, Tile, Panel have Spark equivs
    QE Notes: None
    Doc Notes: None
    Bugs: -
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/Accordion.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/ApplicationControlBar.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/Box.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/Canvas.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/ControlBar.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/HBox.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/Panel.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/TabNavigator.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/Tile.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/VBox.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/ViewStack.as

    Hi DST
    This is a great effort and gesture. thank you on behalf of all the newbies.
    PJ

  • Problems with compressing  files with right hand click. it does not work.

    Problems with compressing files with right hand click.
    I am using the compress function in the Mac OS (File > Compress XX) from time to time. Today it does not work anymore. OS 10.5.6
    I get a message: The content list cannot be created for compressing.
    I tried it with files and folders and keep getting this message. Anybody any idea as to how to fix this

    Thanks I love my macbook!!!!
    I also got further problems such as copy-paste not working etc.
    so I fixed it just this morning by running Applejack 1.5 and am back up running noticing your post.
    thanks for helping though!

  • Archive file with errors in sender file adapter not working! please help!

    Hi Experts,
       I have a file to RFC scenario. the input is a XML file. I have setup the flag in sender file adapter channel for archiving the input files with errors. But it is not working.
    For testing I have used an invalid xML file for example without the main XML tag. I have also tested with a MSWORD file saved with.xml extension. But in both the cases the files are not getting archived.
    My archive location permissions are fine and in fact normal archive operation is happening. That is, if I select the processing mode as "Archive" and gave the Archive directory then files are getting archived. The problem is only with the "Archive faulty source files" option.
    What am I missing? DO I need to do some more configurations?
    What are the prerequisites if any for this option?
    How to test this?
    Please help me! I will be greatfull to you all!
    Thanks & Regards
    Gopal

    and go thru this links
    Creating a Single Archive of the Version Files
    http://help.sap.com/saphelp_nw04/helpdata/en/79/1e7aecc315004fb4966d1548447675/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/31/8aed3ea86d3d67e10000000a114084/frameset.htm
    Note: reward points if solution found helpfull
    Regards
    Chandrakanth.k

  • 'GetInfo' file does not work!

    Hey Folks,
    I have a strange problem...
    I have just migrated on a PPC-G5 from an Intel processor Mac (I have used the migration assistant utility) and the 'GetInfo' file doesn't work. I cannot have access to any file informations.
    The most surprising thing is this problem happens under my account only. There is 2 account on the computer and the 'GetInfo' works fine when I am logged-in under the second account.
    Do some one have an idea?
    Thanks for your help,
    Arnaud

    The thing is I have migrated from a (slow) MacIntel to a (fast) PPC-G5, and not the opposite. The 'Get Info' file function does not work...
    The same rules apply. Migration Assistant migrates wholesale lots of elements of the operating system. You'll be finding a needle in a haystack trying to find the right thing that doesn't belong.
    Your best bet is to erase and install the operating system that came with the G5, and restore piecemeal the documents and applications which will run on a G5.
    A MacIntel should not be slow, unless you depend a lot on old PowerPC applications that require G5 or G4 power. MacIntels may require more RAM as well.
    Unfortunately the differences between CPUs are great enough that plugins and drivers simply don't transfer over well when done by the Migration Assistant.

  • Mult accounts and since I upgrade to 15 fire fox. I can not use. my family We can not open accounts with : multifox 1.3.3 does not work the second person .

    hello,
    I have 2 lab tops.. and have family members that use them.. I used to have FB open with mult family members accounts. Ad of today you updated to firefox 15..
    Now when I go to use multifox 1.3.3 ( that is so you can have mult accounts open. ) .. if trying to go into Fb none of the features work. now since I have upgrade. it use to work fine.
    So, the new FF does not work would like to unistall and go back to the old FF.. where I, can have mult accounts open at the same time and have the funcation work when your on the mult account in FB... Like talk to some one in FB chat. or just look at other items in the accounts.
    if you can tell me how to fix this or can you please give me the old link back.. or tell me how to get the old link back instead of 15.. Because 15 does not work.
    Thanks

    Install or Reinstall OS X from Scratch
    Be sure you backup your files to an external drive or second internal drive because the following procedure will remove everything from the hard drive.
    Boot to the Recovery HD:
    Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    Erase the hard drive:
      1. Select Disk Utility from the main menu and click on the Continue button.
      2. After DU loads select your startup volume (usually Macintosh HD) from the
          left side list. Click on the Erase tab in the DU main window.
      3. Set the format type to Mac OS Extended (Journaled.) Optionally, click on
          the Security button and set the Zero Data option to one-pass. Click on
          the Erase button and wait until the process has completed.
      4. Quit DU and return to the main menu.
    Reinstall OS X: Select Reinstall OS X and click on the Install button.
    Note: You will need an active Internet connection. I suggest using Ethernet if possible
               because it is three times faster than wireless.

  • Hyperlink to a music file does not work, Am I doing it incorrectly?

    Hello there. I am a composer, trying to add all my music samples to the website. I created a title of one of the music samples, then hyperlinked it to that corresponding music file (mp3), so, when you click on that title, it links it to THAT music file. But, it does not work when I click on the link. If I assign the link to another page for example, the link works. What am I doing wrong here. Or is this not possible? I would hate to have a whole list of music files on one page, especially with that "add image here" box on every one of them.
    Any help would be greatly appreciated. Thanks

    The file has to be uploaded to your server and then linked to as an external page using the Inspector/Link/Hyperlink pane with the option to open in a new window.
    You'll get the same effect as with the music example in this demo page but with a full sized window instead of a smaller one: Opening Item in a New, Precisely Sized Window.
    This method would let you add the links to all of your songs to one page. Or you could use a music jutebox for those songs like Roddy has on his iWeb for Musicians site:
    Jukebox Alive
    Juke It Jukebox
    This would reduce your site size considerably. But all these methods require you to upload the audio files to the server and link to them there.

  • Call-Off and Forecast Excel-File does not work anymore?

    The Excel-file e-mail sent does not work any more (Excel says: "The following system error occured: .") when opened with Microsoft Office 2010, which I have on my new
    computer with Windows 7 Professional x64.
    The file is quite important for checking order and forecast quantities retrieved via OLAP-task from 101AS.
    Many thanks in advance for your help.
    ICT ASKNW
    PS: When i use Excel 2007 all work fine. But when i clean Install Excel 2010 it wont work anymore. So but when i upgrade 2007 to 2010 it still working? Can it be true that a
    file of the 2007 Edition is missing on 2010? Thanks for your help!

    Hi Sir,
    Would you like to share us the whole error message? The following system error occured:... We need it to check the issue.
    If you have any update, please feel free let us know.
    Regards,
    George Zhao
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Swf file does not work from InDesign

    I am not sure if this is a Flash or InDesign question, so i will post on both..
    I am trying to embed an “animated” swf file (that was created in flash) into an InDesign layout and then export the InDesign layout to swf. in the resulting html file my navigation works ok but the swf file does not play “animate” when viewed in html or flash. It only shows up as a graphic. 
    I have tried exporting the ID file to xfl and bringing it into flash but then none of my animation works. What am I doing wrong?
    any help would be appreciated.
    thanks
    mattG

    You´re doing nothing wrong. SWF export of InDesign CS4 doesn´t support any media files. You can place videos, sounds and animations into indesign layout, but if you export to SWF, they won´t work in resulting SWF. They work in interactive PDF.
    And you can export your basic layout to Flash CS4 by using XFL export and import those media elements in Flash, but that may be quite a job. I have been strugled a lot with that method. My files used to go really messy when I open them in Flash.

Maybe you are looking for

  • Macbook Pro randomly restarting since installing Mavericks

    Hi guys, I've got a mid-2010 Macbook Pro. Since I installed Mavericks, about 6 months ago, it's started restarting at random (it just goes black and then goes through the reboot cycle. Sometimes it can happen a few times in the same hour - sometimes

  • What is error code -43

    Receiving error code -43 on Finder when attempting operations like change file name and retrieve file.  Does anyone know the source of this problem or what can be done to fix it?

  • Photos  have been found in the iPhoto Library that were not imported

    Every time I open iPhoto 9 (version 8.0.3) I get the following message: "photos have been found in the iPhoto Library that were not imported. Would you like to import them?" Whether I click "yes" or "no" (it doesn't matter) a "recovered photo" folder

  • Help with Acrobat X Pro Config Error

    Hello, I'm looking for some assistance with Config Error 130:11 on Acrobat X Pro running on Windows 7. The message reads: A problem has occured with the licensing of this product. Restart your computer and re-launch the product. Error: 130:11 I'm usi

  • ZipException?-Weblogic6.1-Sp2

    I'm gettting the folling error on server start when it is trying to load/bind the EJB? "java.util.zip.ZipException: error in opening zip file" What is this Zip Exception?? How to getrid of this. Thnx