File not getting deleted using File.delete()

Hi guys,
I have a code like this:
File tempdir = new File("tempdir");
tempdir.mkdir();
File temporaryFile = new File("tempdir\tempfile.txt");
FileWriter writer = new FileWriter(temporaryFile);
// write data into file
writer.flush();
writer.close();
try {
    // Do something
catch (Exception e) {
    // Do something
temporaryFile.delete();
tempdir.delete();The program runs successfully. The directory and the file is created and data is written successfully into it. However, the file as well as directory is not getting deleted at the end of the program. I tried temporaryFile.deleteOnExit(), but this also didn't help.
Can anyone provide some input as to what can be the possible reasons for the file not getting deleted?
Thanks..

I want the file to be created inside the directory I specified. Hence, I put the "\". Please let me know if there is some other way to achieve this. This way I am getting the file created at the location I want.
One more interesting thing which I noticed. Actually this code is part of a JUnit test. In the same JUnit, I am creating new files in atleast 2-3 test methods. But the deletion of files is really random. Sometimes, 2 out of 3 get deleted, sometimes only 1 gets deleted. However, I didn't come through a single instance wherein all the 3 files got deleted. :-(
Also, the directory is never deleted. However, I got the reason behind this. As per the File API, the directory will not be deleted if it is not empty.

Similar Messages

  • File not getting picked by File CC

    Hi Experts,
    Q1)An issue in files not getting picked up by communication channel in an inbound scenario  R/3<XI<-File Port
    Retry interval started. Length: 120.0 seconds
    7/24/09 1:33:14 PM   Error occurred while connecting to the FTP server "XXX.XXX.XX.webdti.com:21": java.net.SocketException: Connection timed out:could be due to invalid address
    7/24/09 1:32:00 PM   Processing started
    Any Quick helps highly appreciated.
    Q2)How can i restart an file adapter?
    Thanks,
    Sudhansu

    Hi Sudhanshu,
       Regarding your first question, check if you are able to  access the file port manually typing the ftp address in internet explorer or any browser.
    Regarding your Q2, read this:
    http://help.sap.com/saphelp_nw70/helpdata/en/1b/d5ef3b1ad56d4fe10000000a114084/content.htm
    (CTRL+F for "To restart the adapter")
    Regards,
    Ravi

  • My LR 4 suddenly no longer recognized my memory cards. I am using the same cards and cameras but consisitently get the error message:"files not imported because the files could not be read. they are jpg and nef files...I am stuck without my workhorse! Any

    My LR 4 suddenly no longer recognized my memory cards. I am using the same cards and cameras but consisitently get the error message:"files not imported because the files could not be read. they are jpg and nef files...I am stuck without my workhorse! Any advice is helpful. This has never happened in 6 years

    answered in your other thread LR 4 suddenly no longer recognizes files.

  • File not getting picked with Sender Adapter

    Hello Experts,
    i have configured file sender adapter which is polling configured directory every 60 sec. But i could see file not getting picked up. when looked into Communication channel monitoring i could see following error:
    Putting message into send queue failed, due to: com.sap.aii.af.ra.ms.api.DuplicateMessageException : Message ID aa2ec9a0-44b3-11dc-9c5b-0003baa19669(OUTBOUND) already exists in database: com.sap.sql.DuplicateKeyException: ORA-00001: unique constraint (SAPDX1DB.SYS_C00120924) violated.
    is this due to adapter cache. we are on SP20.
    has anybody faced this problem earlier?
    Thanks in advance.
    Regards
    Rajeev

    Hello
    actually there was small problem in file generation and hence it was failing in message mapping which is resolved. but still that problem is there when it is attempting to delete the file. hence it is not able to delete that file.
    can we manually clear the send queues or should we refresh CPA cache?
    Thanks
    Rajeev

  • Each time I start up my computer and have my iPhone plugged in, I get a message window that eads "New Wave" file not found in your files....How do I get this file I am missing?

    Each time I start up my computer and have my iPhone plugged in, I get a message window that eads "New Wave" file not found in your files....How do I get this file I am missing?

    Hey Podieboy,
    Thanks for the question. It sounds like you are receiving a message about missing files when you start iTunes. The following resource may provide more information:
    iTunes: Finding lost media and downloads - Apple Support
    http://support.apple.com/en-us/TS1408
    If the file/song is not important, you can simply delete it from your library to avoid this error message in the future:
    iTunes 12 for Windows: Delete songs, playlists, or other items
    http://support.apple.com/kb/PH20391
    Thanks,
    Matt M.

  • Please I can not get a .jar file to run on XP SP3 start/run/cmd/

    I can not get a .jar file to run on XP SP3 start/run/cmd/
    Please help if can figure this out. I'm convinced it is a Windows XP SP3 problem from searching on google and seeing other ppl on XP SP3 with same problem (but no working solution for myself). I'll try to be complete-listing all I've done.
    I had installed: Java SE Runtime Environment v6u14 for Windows Multi-language
    I had checked here it was working properly: http://www.java.com/en/download/manual.jsp
    I'm trying to run this jar file (soht-client-0.6.2.jar):
    http://prdownloads.sourceforge.net/telnetoverhttp/soht-java-client-0.6.2.zip?download
    http://www.ericdaugherty.com/dev/soht/javaclient.html < this is the information for the program.
    (yes the file can be executed and should open the program's window
    I wanted to post screenshot of it but friend that it's working for isn't here)
    _(Please find log of all cmds I did in this post here: http://pastebin.com/f792983df )_
    _I have extracted +'all' the files to: C:\062\+_ (I have tried using other directories, same problem)
    ++I then start/open/run/cmd+
    then I: cd C:\062\+
    then I try various commands - all+ of these do absolutely nothing- meaning no errors, no reply, no window opens, nothing except enters that directoy again:
    java -jar soht-client-0.6.2.jar
    java -jar -client soht-client-0.6.2.jar
    java -client -jar soht-client-0.6.2.jar
    java -jar soht-client-0.6.2.jar soht.properties
    soht-client-0.6.2.jar
    So I try this cmd: java soht-client-0.6.2.jar
    Reply:
    C:\062>java soht-client-0.6.2.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: soht-client-0/6/2/jar
    Caused by: java.lang.ClassNotFoundException: soht-client-0.6.2.jar
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: soht-client-0.6.2.jar. Program will exit.
    I try this cmd:
    java -jar soht-client-0.6.2.jar -client
    Reply:
    C:\062>java -jar soht-client-0.6.2.jar -client
    Unable to load configuration file: -client - java.io.FileNotFoundException: -cli
    ent (The system cannot find the file specified)
    SOHT Java Client
    The SOHT Java Client requires a properties file. Either start
    the application in the same directory as the soht.properties
    file, or specify the file name on the command line:
    java -jar soht-cleint-<version>.jar c:\soht.properties
    So then I do these cmds which produce the exact same error/reply just above; Unable to load..:
    j_ava -jar soht-client-0.6.2.jar -client soht.properties_
    java -jar soht-client-0.6.2.jar -client C:\062\soht.properties
    So then I copy soht.properties to C root and do:
    java -jar soht-client-0.6.2.jar -client C:\soht.properties <same error as above
    Then from other information I have read I right click on the .jar file, select open with Always open with:
    _"C:\Program Files\Java\jre6\bin\javaw.exe"_
    Try again.. same problem.
    Then I do cmd:
    _"C:\Program Files\Java\jre6\bin\javaw.exe" -jar "C:\062\soht-client-0.6.2.jar"_
    does nothing, retry the other commands same thing (either nothing or those same replies)
    Then I read (http://forums.sun.com/thread.jspa?threadID=5384879) someone had the same problem as I and they solved it by uninstalling all Java/reboot/ then install JDK 6 Update 14 with NetBeans 6.5.1 start NetBeans and then it worked for them.
    So I unistalled all Java, rebooted and gave the cmd another try (before re-installing), now a new error, of course:
    C:\062>java -jar soht-client-0.6.2.jar
    'java' is not recognized as an internal or external command, operable program or batch file.
    Then I install  Java SE and NetBeans Cobundle (JDK 6u14 and NB 6.5.1) Final Release/ reboot/ open Netbeans/
    go to test java page; all is good, run cmds again -and still nothing..
    C:\062>java -version
    java version "1.6.0_14"
    Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
    Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)
    I reassociate program with: C:\Program Files\Java\jre1.6.007\bin\javaw.exe_
    same thing.. nothing
    Thank you very much for your time :D_
    PS. My computer has been newly reformatted so needing another reformat I'm sure is not the solution.

    Thank you very much for your replies Taggert_77 & swmtgoet_x :D
    Taggert77_: I have never used NetBeans. I only installed it in the bundle as I had read on another post that somehow installing the bundle magically helped another user with the same problem (he didn't know why it worked after that either).
    Before XP SP3 I was able to execute .jar file through cmd prompt. Now I am not.
    This file is executable, grab it and you will see. Here is a screen shot (program in front is FlashFXP, behind is the cmd prompt and what should happen):http://www.freeimagehosting.net/uploads/53273b4ddf.jpg
    swmtgoetx_: I only did the other cmd's to try to make it spit out something, anything lol :D
    The proper cmd is simply: java -jar soht-client-0.6.2.jar
    I did give your cmd a try, and it produced nothing :( (just like the other correct cmds)
    java -client -jar soht-client-0.6.2.jar soht.properties
    Thank you again...the mystery remains
    PS. If you do a search for this you'll find an amazing amount of XP SP3 users with the same problem and no solution posted that I could find except one chap that did the unistall install order that I did above).

  • "could not get an output file for the document (error RWI 00314)"

    Hi
    We are getting the following error when running the Webi Reports "could not get an output file for the document (error RWI 00314)". The issue seems to be related to Tomcat Memory Heap size, our Tomcat Java heap Size is 1024MB. We were able to resolve  the issue by restarting the Tomcat. We cannot restart the Tomcat in Prod if this is happening frequently.
    Can some one please suggest  any other solution other than restarting the Tomcat frequently, our platform is BOBJ XI 3.1 SP3 with FP 3.1 our Wndows OS is 32 Bit.
    Thank's for your help

    Hi Sreeram,
    Earlier i also faced same kind of problem.
    To solve this kind of problems you need to shutdown the server.
    second thing is when patches missed that time also you will get this kind of problem.
    check j2ee connection is it properly working or not?
    Regards,
    samar reddy.

  • HT3775 i can not get my mp4 file to play on quick time player

    I can not get my mp4 file to play on quick time player

    Contact the manufacturer of the motocycle system.  Many systems are not compatible with iOS devices but work fine for the simple iPods.

  • SQLite encrypted Database does not get attached Using Adobe Air,Why?

    Hi,
    Any one knows the solution, am trying to attach the encrypted SQLite database adobe air-adobe flex bulder , it does not get attached using sqlconnection.attach throws error, though the given key is correct, but it gets open using sqlconnection.open with the same key, any one knows the solution, how to attach the encrypted data base, since am using two data base one is opened and another must be attached to the existing ,thanks in advance. using adobe air- flex related. i use the following code
                   databaseFile1 = File.applicationStorageDirectory.resolvePath("Sample_1.sqlite");
                   databaseFile2 = File.applicationStorageDirectory.resolvePath("Sample_2.sqlite");
    dbConnection.open(databaseFile1, SQLMode.CREATE, false, 1024, secKey);
    dbConnection.attach("db2",databaseFile2,null,secKey);
    got the following error.
    ERROR #3125 Unable to open the database file.

    And I would say more "this is the issue" !
    It should be possible as it is clearly stated in the doc :
    public function attach(name:String, reference:Object = null, responder:Responder = null, encryptionKey:ByteArray = null):void
    with 
    encryptionKey:ByteArray (default = null) — The encryption key for the database file. If the attach() call creates a database, the database is encrypted and the specified key is used as the encryption key for the database. If the call attaches an existing encrypted database, the value must match the database's encryption key or an error occurs. If the database being attached is not encrypted, or to create an unencrypted database, the value must be null (the default).
    so with a same encryptionkey, I (and this should be the same for FinalTarget) can open the encrypted db but not to attach it... quite strange.

  • Stranger error:Old file not found.However,a file of the same name was found

    Hi All,
    I appologise if its not the right forum...
    I am a bit baffeled here by the following error when I am trying to install Java SDK or just JRE.
    I upgraded my windows 2000 box to win XP home edition, installed the latest updates etc and then tried to install java....
    and got the following error
    bin\appletviewer.exe:
    Old file not found.However, a file of the same name was found.No updates done since file contents does not match.
    I have removed everything from system that I could imagine might be using Java directly or indirectly. No JRE on the system, no old java folder under C: drive etc, But I still get the same error. I have never come accross a stupid error like this before. Any help will be appreciated. Thanks
    Message was edited by:
    Khalid.Ali

    hunmm..thanks for the reply, I will try to find appletviewer.exe, however, my guess is that file should be there cus I am just trying to install it from standard java SDK installation.
    Yes I did not do checkdisk and I will do that and post my findings

  • Encode Video Files not working for avi files

    Hi,
    I've been trying to convert some .avi files to apple format using Lion's native 'Encode video files' function however keep getting a 'avconvert: source file not found for source file://fileparthhere avconvert: failed to create an export session. Check setup
    I can't work out why as this has worked before in Lion and works fine for other video formats. The only thing I've done is remove Final Cut Express HD and can't add it again as I don't own it anymore
    Suggestions? Is there a encoder to make this work or should it work anyway?
    Thanks

    If you click Yes the project file will be updated when you save it. That has nothing to do with the media.
    Are the Lesson and Media folders still in the Book Files folder (or whatever it's called)?
    Select one of the clips in the browser and use Edit>Item Properties. One of the first lines is Source. That gives you the file path for where your media is supposed to be located. What does it say? If nothing is there, use the File>Reconnect function and point the application to where the media is located.

  • I just signed the creative cloud, and I'm not getting to use the purchased software. thank you

    I just signed the creative cloud, and I'm not getting to use the purchased software. thank you

    Rodrigo_1405 do you receive any specific error messages?  For information on how to install the Adobe Creative applications included with your membership please see Creative Cloud Help | Install, update, or uninstall apps.

  • File-RFC-File-File not getting deleted.

    Hi all,
    In File-RFC-File scenario i have used "Delete" as the processing mode for Sender file adapter.RFC was execured successfully and successful message was shown in SXMB_MONI.But at the same time there was an exception thrown in sender and receiver file adapters as given below:
    Error when getting an FTP connection from connection pool. com.sap.aii.af.service.util.concurrent.ResourcePoolException:unable to create new pooled resource : FTP Ex:User piuser cannot login.
    Both the CC's werein error status.
    The file from source location was not deleted even after the successful processing of the message in moni. Because of this sender file adapter was reading the same source file again and again which created multiple response entries in the moni.
    Could some one tell me why the file was not deleted from source location?How can the sender adapter read the message again when the above exception was thrown?
    Regards,
    Lekshmi.

    HI Lekshmi ,
    Check whether PIUSER has sufficent authorization ., Delete that channel and  create a dummy one to test and see whether
    you are getting the same error
    Check this threads a similar discussion is going on here , may be you need authorizations .
    Re: com.sap.sql.DuplicateKeyException in file sender adapter
    Re: Processing mode - DELETE not working in Synchronous mode (File - RFC - File
    Regards
    Ninad

  • Files not moved to trash when deleted

    I'm running 10.7.5 and something changed recently.    It asks  me for my password to delete the file and then the file never shows up in the trash.    When I do a GET INFO on the disk the space is still consumed.   I have no way of reclaiming this deleted space.   I can't get to the file any more but its consuming resources.   I'm running out of space on my disk and need some assistance.
    Any ideas?
    Rick

    Is AppZapper what you're looking for?
    (22348)

  • File not getting created at the Reciever

    Hi All,
    I have implemented a simeple file to file scenario. The file is getting deleted from the source directory but is not getting created in the target directory. It shows a checkered flag in SXMB_MONI . When i do Communication Channel monitoring for the reciever Comm. Channel, it shows no messsages .
    I have refreshed the Cache in Integration directory. it is still not working.
    I tried using a different Communication channel with the Mail adapter that is working fine.
    I cant figure out what the problem is please help.
    Many Thanks,
    Neha

    Hi! Neha,
    Here i want to add some points :
    Even I faced same problem in project....... then I followed this procedure...
    My scenario is FILE TO RFC via FTP Server in file adapter.
    Here issue is file is picking from FTP and showing success in MONI but data is not reaching to BW system..
    Most of the times I checked and I did successfully.
    Main issue are due to:::
    1. Check Queues in Inbound queue SMq2
    2. Trace teh step by step in message flow in message monitoring that means check whether message flows
            from a) Intergration Engine
                   b) Adapter Engine..
    3. Check and trace the flow in Message monitoring in Run Time work Bench
    4. Check Status of Receiver communication Channel in Communication channel Monitoring
    5) Check whether Business Services are Scheduled in Availability Time planning or not
    6  Also Check in Visual admin whether the services are released or not if any others are might using the same servivcees and cahnnels and suppose if they are scheduled or not
    7. Do Cache Refresh mainly SXI CACHE, ADAPTER ENGINE CACHE
    8 Finally if still not resolved J2EE ENgine SOFT Restart..instead of doing restarting entire XIengine server.
    Once the Server is started then defintely all the messages if suppose if 40 messages are picked from source directory and not reached to Target then all those definetely 100% become success and reached
    Note:: All above needs to check only if development part is correctly configured.
    Also check the Receiver target and sender directory Permissions in FTP Server i.e., rwx permissions okay
    Thanks
    Amar Srinivas Eli
    Reward Points if useful

Maybe you are looking for

  • Problem with colors after upgrading to Lion

    After upgrading to Lion, I could no longer distinguish between very light greys (e.g., #f8f8f8) and white (#ffffff) on my laptop monitor. The difference is readily apparent on many websites. If I plug my laptop into an external monitor, the problem g

  • Problems Viewing .pdf Template Created with Adobe

    I created a .pdf template using Adobe LiveCycle Designer. After I upload this template, I can not view the report. Can I only create templates using the BI Publisher plugin for MS Word?

  • Is multiple receiver determination possible in a  Sync scenario

    Hi I have a scenario - Syncronous interface -> RFC to JDBC. There are two target databases. based on the one of the input fields in the source message I have to route the database call to one of the two databases. When i put the condition (which is m

  • Camera Raw Update for Nikon D800

    Does anyone know if there is a camera raw update for the new Nikon D800 in iphoto 08 version 7.1.5 and Aperture 2.1.4?

  • Purchasing a Mac Pro

    Sorry, but I was not sure where exactly to post this but I wanted to know if there was another site or place I can visit where I can purchase a Mac Pro rather than getting it from the Apple Store. There are a few things that I dont want that the Appl