Why is my Zip file being created with size of O KB?

I have the following code
public static int createZip (String directory)
                   throws IOException {
     File path = new File( directory );
     File outZip = new File("c:\\wip\\sams9dbExport.zip");
     boolean boo = outZip.createNewFile();
     FilenameFilter filter = new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.endsWith(".xml");
    if ( outZip.exists() ) System.out.println("File exists");
     System.out.println(" Files and filters made");
     // These are the files to include in the ZIP file
     String[] fileList = path.list(filter);
    // Create a buffer for reading the files
    byte[] buf = new byte[1024];
    try {
        // Create the ZIP file
        String outFilename = "sams9dbExport.zip";
        ZipOutputStream out = new ZipOutputStream( new FileOutputStream( outFilename ) );
        // Compress the files
        for ( int i=0; i < fileList.length; i++ ) {
            FileInputStream in = new FileInputStream( "c:\\wip\\"+fileList[i] );
             System.out.println( fileList[i] );
            // Add ZIP entry to output stream.
            out.putNextEntry( new ZipEntry( "c:\\wip\\"+fileList[i] ) );
            System.out.println("Added an entry");
            // Transfer bytes from the file to the ZIP file
            int len;
            while ( ( len = in.read( buf ) ) > 0 ) {
                out.write( buf, 0, len );
            // Complete the entry
            out.closeEntry();
            in.close();
        // Complete the ZIP file
         out.close();
    } catch (IOException e) {
         System.out.println( e.toString() );
         return 0;
    return 1;
}And I get the following output
SQL> @ziptest
File exists
Files and filters made
AH_QUERY.xml
Added an entry
myclob.xml
Added an entry
myclob1.xml
Added an entry
myclob2.xml
Added an entry
PERSONNEL.xml
Added an entry
PERS_ALG.xml
Added an entry
sampledoc.xml
Added an entry
ut_ah_query1.xml
Added an entry
ut_provider.xml
Added an entry
PL/SQL procedure successfully completed.
SQL>
But my file is created empty. I previously added a println statement in the while loop to see if it was reading and writing bytes and it was.
Any ideas?

I have the following code
public static int createZip (String directory)
throws IOException {
File path = new File( directory );
File outZip = new
= new File("c:\\wip\\sams9dbExport.zip");
boolean boo = outZip.createNewFile();So these two lines will create sams9dbExport.zip with size 0 bytes, if file didn't exist.
No need to do that....
try {
// Create the ZIP file
String outFilename = "sams9dbExport.zip";
ZipOutputStream out = new ZipOutputStream(
tStream( new FileOutputStream( outFilename ) );Probably you are looking a wrong "sams9dbExport.zip" -file. Your application will create two "sams9dbExport.zip"-files, one into wip-folder with 0 bytes, and other into default directory.
>
But my file is created empty. I previously added a
println statement in the while loop to see if it was
reading and writing bytes and it was.
Any ideas?

Similar Messages

  • Duplicate text files being created with ~ appended

    Whenever I edit a text file with TextEditor and save it, a duplicate file is created with a ~ appended to the end of the name.
    Example:
    After editing and saving my_file.txt my_file~.txt is also created.
    The result is I get two files with exactly the same contents.
    my_file.txt
    my_file~.txt
    I would really like to stop it from doing this. It clutters up everything. It has done this since I first installed the OS. My file system format is Mac OS Extended (Journaled). Any suggestions?

    I looked through the preferences for TextEditor. I had "Delete the automatic backup file unchecked". I think checking this option will fix the problem.

  • Zip file is created with 0 bytes

    In my below code, I am trying to zip a folder containing files and folders. But the zip file is getting created with 0 bytes.
    Could anyone please tell me what is wrong in my coding.
    private void jButton5ZipActionPerformed(java.awt.event.ActionEvent evt)
         File sgm=new File(jTextField1Text);//jTextField1Text is the filename I am selecting from the jTextField
         File tempXML=new File(sgm.getParent());
         String[] children = tempXML.list();
         for(int i=0;i<children.length;i++)
              File renamingFile=new File(tempXML,children);
              CreateZipFile czf=new CreateZipFile();
              try
                   czf.doCreate(renamingFile);
              catch (FileNotFoundException ex)
                   ex.printStackTrace();
              catch (IOException ex)
                   ex.printStackTrace();
    ==============================
    void doCreate(File dir) throws FileNotFoundException, IOException
         String[] filenames=new String[]{dir.toString()};
         byte[] buf = new byte[1024];
         try
              // Create the ZIP file
              String outFilename = "C:\\outfile.zip";
              ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename));
              for (int i=0; i<filenames.length; i++)
                   FileInputStream in = new FileInputStream(filenames);
                   // Add ZIP entry to output stream.
                   out.putNextEntry(new ZipEntry(filenames[i]));
                   // Transfer bytes from the file to the ZIP file
                   int len;
                   while ((len = in.read(buf)) > 0)
                        out.write(buf, 0, len);                    
                   // Complete the entry
                   out.closeEntry();
                   in.close();
              // Complete the ZIP file
              out.close();
         catch (IOException e)
    Message was edited by:
    Simmy

    If I give File [] filenames =
    dir.listFiles();an error is thrown for the line
    out.putNextEntry(new
    ZipEntry(filenames)); as
    cannot find symbol
    symbol: constructor ZipEntry(java.io.File)
    location: class java.util.zip.ZipEntry
    There's no constructor that accepts a File as argument. There's only this
    ZipEntry(String name)
              Creates a new zip entry with the specified name.
    ZipEntry(ZipEntry e)
              Creates a new zip entry with fields taken from the specified zip entry.
    Check the API
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/ZipEntry.html
    regards,
    MAnuel Leiria                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • LCK files being created with PAK files when processed through ODDC

    I'm encountering a problem where after commit of a batch in ODDC the files are transferred to the server, but the PAK files are accompanied by a LCK file that is preventing the Distributed Document Capture service from picking them up and processing them. This started occurring after ODDC Patch 4 (14538424) was applied. I'd blame the patch, but not all users encounter the problem. Users encountering the problem are using Win7 and IE9. That said, users that don't encounter the problem are using the same OS and browser. Has anyone encountered this before? What was the resolution? I suspect it's a browser setting, but haven't identified it yet.
    Thanks

    I stumbled on a link in the oracle forum which says that the "create or replace package XXX" at the start of the PL/SQL procedure when run seems to intermittently cause the ORA-04068: existing state of packages has been discarded problem.
    As per the solution suggested an “alter package XXX compile" can be executed after the changes are made and then we would no longer get the error in BPEL/ESB and dont have to bounce the server too.
    __http://forums.oracle.com/forums/thread.jspa?threadID=185762_
    However the above solution does not seem to resolve the issue.
    Any help in this regard would be highly appreciated.
    Thanks,
    Deepthi

  • Accounts being created with administrative group rights

    Hello,
    The server is a Windows 2003 R2 Enterprise fully patched used for Shared Hosting purposes.  It runs Hsphere control panel.  I am trying to identify how the following hack is happening. 
    1) There are users being created with Administrative group rights.   Below is the EventViewer log for the user creation:
    User Account Created:
         New Account Name:    username
         New Domain:    PCNAME
         New Account ID:    PCNAME\username
         Caller User Name:    PCNAME$
         Caller Domain:    DOMAINNAME
         Caller Logon ID:    (0x0,0x3E7)
         Privileges        -
     Attributes:
         Sam Account Name:    username
         Display Name:    <value not set>
         User Principal Name:    -
         Home Directory:    <value not set>
         Home Drive:    <value not set>
         Script Path:    <value not set>
         Profile Path:    <value not set>
         User Workstations:    <value not set>
         Password Last Set:    <never>
         Account Expires:    <never>
         Primary Group ID:    513
         AllowedToDelegateTo:    -
         Old UAC Value:    0x2DAB2B0
         New UAC Value:    0x2DAB2B0
         User Account Control:    -
         User Parameters:    <value not set>
         Sid History:    -
         Logon Hours:    <value changed, but not displayed>
    There exists entries as well where the primary group ID is changed to the Administrative group, but I am omitting such.
    2) I tried to identify what Caller Logon ID:    (0x0,0x3E7) means.  I found out from here:
     http://blog.joeware.net/2013/01/14/2667/ that I can use LogonSessions.exe to identify it.
    Output from LogonSessions.exe is pasted below (snippet):
    [0] Logon session 00000000:000003e7:
        User name:    DOMAINNAME\PCNAME$
        Auth package: NTLM
        Logon type:   (none)
        Session:      0
        Sid:          S-1-5-18
        Logon time:   9/11/2014 12:41:53 PM
        Logon server:
        DNS Domain:   
        UPN:          
            4: System
          316: smss.exe
          364: csrss.exe
          392: winlogon.exe
          440: services.exe
          452: lsass.exe
          628: svchost.exe
          756: LMAgent.exe
          840: svchost.exe
         1000: spoolsv.exe
         1252: avagent.exe
         1268: camWMIAgent.exe
         1324: cissesrv.exe
         1380: cpqrcmc.exe
         1404: vcagent.exe
         1440: svchost.exe
         1480: HsQuotas.exe
         1740: inetinfo.exe
         1780: EmailAgent.exe
         1856: snmp.exe
         1884: sysdown.exe
         1920: smhstart.exe
         2192: svchost.exe
         2388: cmd.exe
         2396: hpsmhd.exe
         2444: cqmgserv.exe
         2464: cqmgstor.exe
         2484: HSphere.exe
         2596: wmiprvse.exe
         2676: cmd.exe
         2684: rotatelogs.exe
         2692: cmd.exe
         2700: rotatelogs.exe
         2732: searchindexer.exe
         2812: hpsmhd.exe
         2824: cqmghost.exe
         2852: svchost.exe
         3044: cmd.exe
         3052: rotatelogs.exe
         3080: cmd.exe
         3088: rotatelogs.exe
         5452: svchost.exe
         5596: GravitixService.exe
         7392: csrss.exe
         7232: winlogon.exe
         6888: csrss.exe
         9832: winlogon.exe
        10388: wawrapper.exe
        10352: cpqnimgt.exe
         9496: msiexec.exe
         6068: w3wp.exe
         4748: webalizer.exe
    3) I also learned from http://support.microsoft.com/kb/243330/en-us that   Sid:          S-1-5-18 means:
    SID: S-1-5-18
    Name: Local System
    Description: A service account that is used by the operating system
    That is all great info, but I am not sure I can put together what I have learned to attempt and get closer towards identifying how in the world users are being created and then being assigned administrative group rights.
    I am a Linux person mostly, but I am comfortable following a properly explained thread regarding windows 2003 R2 Enterprise issues.
    The server is fully patched and it is running Lumension security product.  What's more, Norman Malware tracker, tdskiller.exe (Kaspersky) and McAfee rootkitremover.exe have been run without any apparent Malware/Virus infection
    Hope someone with advanced admin skills can advise.
    Thank you

    Hi,
    You mentioned that, “I am trying to identify how the following hack is happening”, would you please tell us that why did you think the event represent a hacking behavior?
    In a Shared Server Hosting environment, the underlying hosting control panel tool (Hsphere in this case) should be creating only virtual FTP users with a specific group.  So no users with Administrative group should be ever created.  If this happens,
    it constitutes a breach of server security=positive hacking attempt.
    >how in the world users are being created and then being assigned administrative group rights.
    In addition, would you please be more specific about this question? Did you find the event message on a domain joined machine?
    I want to be able to understand in full how/what process is allowing users to be created with Admin rights.  In other words, I want to know what IP was used to issue the command, if ASP.net was used (abused in this case), or anything else related to
    it so that we can patch this particular hole.
    Best Regards,
    Amy

  • Mysterious files being created in pages. Unable to unlock or delete them.

    Mysterious files being created in pages. Unable to unlock or delete.

    It turns out that you cannot update or delete a Syndication Map that is currently assigned to a Port in the Repository.  You must remove the map from the Port in the Repository and then you can change and/or delete them. 
    1) bring up the MDM Console
    2) Unload the repository
    3) drill into Admin ~ Port
    4) Remove or change the map associated to the port
    5) Load the repository
    6) Then you go into Syndicator and either Update the Map or Delete it
    It had nothing to do with security.
    Thank you for your help.

  • Unable to find ODI_SAmple_DATA.zip file to work with oracle profiling.

    I am unable to find ODI_SAmple_DATA.zip file to work with oracle profiling.Any help regarding profiling???Do i need to
    copy it from sw installation folder.?How profiling is different or related to odi data quality???Do we take source data twice -
    1) For ODI target load
    2)For profiling into entities.

    Try:
    http://www.oracle.com/technology/products/oracle-data-quality/pdf/oracledq_sample_data.zip
    and
    http://download.oracle.com/otn/nt/ias/101340/oracledq_sample_directory.zip
    Hope this helps.
    G

  • I am facing issue when opening flash files in Flash CC. (error:- This file was created with a later release of Flash Professional and might contain new features that would be lost when saved in the current format.)

    I am facing issue when opening flash files in Flash CC. (error:- This file was created with a later release of Flash Professional and might contain new features that would be lost when saved in the current format.)

    Wow. Okay...
    I'll let the real veterans in this forum tackle your issues one after the other. But, I can tell you, all will be well.
    My only comment would be re: your computer specs:
    BJReis wrote:
    .  This may be due to somewhat older equipment:
    GHz Intel Core Duo MacBook Pro with a 4GB memory computer with Ddr3 running OSX 10.8.4
    To be completely honest, FCPX is a RAM hog. It just is. But, RAM is relatively cheap, and the pay-off is good.
    4GB is right on the edge, IMHO. 16G is ideal.
    I wish you luck, hang in there, and standby for more help.

  • Files/projetc created with PRemiere 6.5. Supported by PRemiere Element 9 ?

    Hi all,
    I think to change my old powerbook G4 for an Imac intel core duo.
    What about my files/project created with Premiere 6.5 if I want to open them with Adobe Premiere Element 9 ?
    Is it possible ? Can i still work/modify them ?
    Regards,
    A.

    I would recommend contacting Adobe for that answer, your question is about their software so I would think they would be the best people to ask.
    Roger

  • Are cp file extensions created with Captivate 4  compatable with Captivate 8?

    Are cp file extensions created with Captivate 4  compatable with Captivate 8?

    Hi there
    I believe you will need a copy of version 5 or 6 to open the CP with and convert to a CPTX. Then you can open using 8.
    Additionally, you may discover that things become a bit mangled during the upgrades. Many have not gone smoothly and have forced a rebuild of the project.
    Cheers... Rick

  • How to prevent unauthorized extraction of the zip files I created.

    Hi all,
    Can anyone help me in knowing abt this.
    Is there any way to prevent unauthorized extraction of the zip files I create using Java.
    Plz help friends.
    Thanks in Advance.
    -James

    Since you already found out that Java's zipping methods don't implement password protection, all you could possibly do is encrypting the contents.

  • XMP files not being created with DNGs...

    I'm used to using Bridge with ACR to process Nikon NEFs. But a recent camera update has me experimenting with converting the D3's NEFs to DNG files and editing them with CS2 and Bridge 1.04 which works better on my system. I've also experimented with CS3 and Bridge 2.1.1.9 with the same DNG files.
    In both cases XMP files are not being created when working with DNG files. I have enabled "Save image settings in : Sidecar ".xmp" files" turned ON. But they do not seem to be generated and I assume the ACR adjustments are being embedded in the DNG file. Meanwhile doing edits on NEF files continues to create .xmp files as expected.
    I find .xmp files to be very useful and I'm wondering why they're missing with DNG files? Are they hiding somewhere other than in the same folder that the images reside in?
    Thanks.
    Russell

    > The information contained in the XMP file is stored in the DNG file so there is no need for a separate file.
    Aww, yuck!! That's a real drag...
    When editing lots of files (yesterday's shoot produced 8GB) I back everything up to off-line storage and then, after doing all my edits and crops in ACR, I only have to copy over the small XMP files which takes no time at all.
    So if I re-edit the DNG with ACR I have to re-copy ALL the files again to the off-line storage.
    I used to sometimes even save 2 versions of the xmp files when I needed 2 different crops of the same images, such as doing a wide screen 'cinema' crop for a corporate client's Intranet presentation of their event, as well as more standard crops to be used for their newsletters.
    Guess I won't be using DNG any more..
    Thanks for the help Kees :-)
    Russell

  • Why is the .jar file not created??

    the error i get is :
    com.sun.kvem.midletsuite.InvalidJadException: Reason = 36
    Error in opening jar file: list.jar
    and in the \j2mewtk\2.5.2\apps\list\bin there are only 2 files are :
    list.jad
    MANIFEST.MF.
    Why is that so?
    Edited by: angelusPiper on May 7, 2009 7:24 AM

    Hi Sudipto,
    I'm assuming that you used the <wsgen> Ant task (in your build.xml) to create this
    web service, right?
    Are you sure the client.jar file isn't in the web-services.war? You can verify this
    by extracting this file (web-services.war) from the .ear for your web service, and
    viewing its contents with WinZip (or the jar.exe utility that comes with the JDK).
    There is a way to create client code without having a client.jar (or a WSDL document),
    but it takes a little more work :-) I have attached a "heavily commented" example
    of this, at the bottom of this post.
    Regards,
    Mike Wooten
    "Sudipto" <[email protected]> wrote:
    >
    Hi,
    I have developed a web service for our Internal network. I have deployed
    the web
    service onto weblogic 6.1 and have been able to obtain the wsdl file. I
    have coded
    my java client, but to compile and run the client, I require the client.jar
    file,
    which weblogic should create on its own once the actual web service is successfully
    deployed. wl server is not able able to create the client.jar file and hence
    I am
    unable to run the client. Could anyone tell me why the client.jar file is
    not being
    created and is there any workaround for coding the java client without using
    the
    client.jar file.
    Thanx
    sudipto[NoWSDLWeatherClient.java]

  • Auto Save folder not being created with new project

    Just recently I've noticed that when I start a new project there is no auto save folder being created.  I have all preferences the same (auto save every 10 min with a max of 50 and save next to project files).  I have no idea why this started or what I can do to fix it. 

    So it seems to be working now.  I went back through other projects that have been open for some time and the most recent auto save file I could find for any of them was from Oct. 8th.  So auto save hasn't been working at all.  What I did was go into preferences and change the interval a little and the frequency from where I had had it since intial set up.  That seemed to have told it to turn it back on for some reason.  It's really weird.  I guess I'll just keep an eye on it, but people may want to check there folders just in case the same issue is happening.  I didn't realize it until today and it's been happening for a couple of weeks apparently. 

  • Cant get list of files from a folder (even though the folder and files are created with the same app)

    Ok so each character rolled with my app gets saved as an html file in a folder i create on the sdcard called RpgApp
    the code to do this is 
    private async Task saveToHtmlCharacter(string name)
    StorageFolder externalDevices = Windows.Storage.KnownFolders.RemovableDevices;
    StorageFolder sdcard = (await externalDevices.GetFoldersAsync()).FirstOrDefault(); //Windows.Storage.ApplicationData.Current.LocalFolder;
    var dataFolder = await sdcard.CreateFolderAsync("RpgApp",
    CreationCollisionOption.OpenIfExists);
    var file = await dataFolder.CreateFileAsync(name+".html",
    CreationCollisionOption.ReplaceExisting);
    using (StreamWriter writer = new StreamWriter(await file.OpenStreamForWriteAsync()))
    writer.WriteLine("<html><head><title>Character File for " + z.charNameFirst + " " + z.charNameSecond + "</title></head><body>");
    //trimed for the post
    now this as i say works perfectly and i can confirm that the files show up in the "RpgApp"folder
    now the next step is to have the app read the names of each of those html files and create a seperate button for each one named for the filename and with the filename as content (later i will link them up to load the html file they are named for in a webbrowser
    panal)
    here is the code that *should* do that
    private async Task readFiles()
    z.test.Clear();
    StorageFolder externalDevices = Windows.Storage.KnownFolders.RemovableDevices;
    StorageFolder folder = (await externalDevices.GetFolderAsync("RpgApp"));
    IReadOnlyList<StorageFile> fileList = await folder.GetFilesAsync();
    //z.test.Add("dummy");
    foreach (StorageFile file in fileList)
    z.test.Add(file.Name);
    public async void buttonTest()
    await readFiles();
    CoreDispatcher dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
    await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    foreach (string name in z.test)
    Button button1 = new Button();
    button1.Height = 75;
    button1.Content = name;
    button1.Name = name;
    testStackPanal.Children.Add(button1);
    now i say should as what i get is an error of "A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.ni.dll" (2 of them in fact one after another)
    more detailed error is at http://pastebin.com/3hBaZLQ9
    now i went through checking line after line to find the error and line that causes it is:
    StorageFolder folder = (await externalDevices.GetFolderAsync("RpgApp"));
    in the readFiles method
    i checked to make sure the case is right etc and its spot on, that IS the folder name, and remember my app creates that folder and creates the files that are inside that folder (and only files my app creates are in that folder) so it should have access
    im 100% stuck its taken me all day to get the files to save and now i cant get them to list correctly
    I have tested the button creation function with fake list data and that worked fine, as i say the error is when i tell it to look at the folder it created
    all help most greatfully recieved

    this was actually solved for me on another forum thread 
    async Task<bool> continueToReadAllFiles(StorageFolder folder)
    if (folder == null)
    return false;
    if (folder.Name.Equals("RpgApp", StringComparison.CurrentCultureIgnoreCase))
    var files = await folder.GetFilesAsync();
    foreach (var file in files)
    test.Add(file.Name);
    return false;
    var folders = await folder.GetFoldersAsync();
    foreach (var child in folders)
    if (!await continueToReadAllFiles(child))
    return false;
    return true;
    public async void buttonTest()
    test.Clear();
    StorageFolder externalDevices = Windows.Storage.KnownFolders.RemovableDevices;
    var folders = await externalDevices.GetFoldersAsync();
    foreach (var folder in folders)
    if (!await continueToReadAllFiles(folder))
    break;
    //.... commented out
    ...now i say solved this is more a workaround...but it works.
    I would love to know why we cant just scan the RpgApp folder instead of having to scan the whole dc card and disregard all thats not in the RpgApp folder

Maybe you are looking for