How to delete this file

I would like to delete an existing file so I can create a new version of it (I want to delete it to prevent update problems).
Tried lots but it never actually deletes it. Any suggestions on how to solve the problem?
Thanks.
public void writeToFile(String message, String userName){
      (userName+".wri").delete();  //delete the file
     try{    File diaryFile = new File (userName+".wri");
     diaryFile = new File (userName+".wri");
     RandomAccessFile raf = new RandomAccessFile(diaryFile,"rw");
    raf.writeBytes(message);
    catch (Exception e)
    {     System.out.println(e);}

You're not trying to delete a File, you're trying to call delete() on a String:
(userName+".wri").delete();To delete a File, do this:
File file = new File(filename);
file.delete();

Similar Messages

  • How to delete music file that is not downloaded into iTunes?

    Im having a problem deleting a file I asked to open a music file, with itunes.
    I was on a site called mp3skulls trying to listen and possibly download a file. I accidently requested it to be opened with itunes and as it did open with itunes and played. I can't simply delete it. It's not downloaded into my mac nor is it downloaded into itunes. It seems like it is being streamed from the site onto my itunes. I tried to find a delete option but there isn't one and i tried just dragging it to my trash can but it is still there playing.
    there is a symbol right in front of the name that looks like this ((.)) (there's a dot in the middle) if that helps anything.
    I just need to know how to delete this file cause i do not want to keep it.
    Thank you!

    If it is a system file and even if the file is corrupted, it cannot be deleted.
    Try reinstalling phone software using Nokia suite if the phone supports Nokia suite and an USB port.
    -------------------If this post helped you, click on accept as solution.------------------
    -----------------------------Appreciate by clicking on white star.----------------------------

  • How to delete alias files? I already delete the files but the alias is still at ALL MY FILES under MOVIES? Please help.

    "The alias "title.TS.Xvid.MP3-ADTRG.mp4.vc.m4v" can't be opened because the original item can't be found." How to delete this file?

    Drag it to the Trash. (Mac 101).

  • HT1923 In trying to delete the Apple file in the Program/Common File I can delete all contents except the Internet Services folder.  Thus preventing me from deleting the Apple FIle.  Error message says I need permission to delete this file.  How do I proc

    Trying to delete the Apple Folder from Program Files/Common Files.  I can delete all the contents except for the Internet Services folder which prevents me from making the deletion.  The error message says "you need permission to delete this file".
    Discovered this problem when trying to upgrade from my 3G iPhone to a new 5S iPhone unsucessfully.

    See note 3 of Troubleshooting issues with iTunes for Windows updates.
    tt2

  • Question:  why isn't how to delete a file available.

    How come you have to search for the information on how to delete a file from Adobe Reader.   This should be in the instructions on how to use with how to download.  Does anyone agree?

    If it is a system file and even if the file is corrupted, it cannot be deleted.
    Try reinstalling phone software using Nokia suite if the phone supports Nokia suite and an USB port.
    -------------------If this post helped you, click on accept as solution.------------------
    -----------------------------Appreciate by clicking on white star.----------------------------

  • Anyone knows how to delete a file from a directory?????

    hi there
    anyone has any idea on how to delete a file from a directory? delete(String filename)? thank you.

    Hi,
    Check this link.
    Gives you an example code to show how to delete a file.
    http://examples.oreilly.com/jenut/Delete.java
    Hope this helps.
    Roopasri Vittal
    Developer Technical Support
    Sun Microsystems
    http://sun.com/developers/support

  • How to delete a file in Keynote Remote for iPhone4?

    Any one know how to delete a file in Keynote remote app for iPhone4? I uploaded a Keynote file from iDisk to my iphone and I can't delete the file. The file does not show up when I connect my phone to iTunes.
    I also cannot connect my Iphone to Keynote anymore because of this file.

    The file is actually in the Keynote app and not the Keynote remote app for iPhone.

  • How to delete recent file history in adobe reader in Mac PC ?

    How to delete recent file history in Adobe Reader in Mac PC ?
    In Adobe Reader - Edit - Preferences - select Documents in the left panel and change the "Documents in recently used list" to 0. Yes ! the file history is gone But when you set back the value, you will see the file history again. This is not the way to do...
    I have checked all the preference or setting. I couldn't found any clear recent file history in adobe reader.
    Please help ! Thanks !

    First off, you CANNOT set recent documents to zero. The absolute minimum it will accept is 1. And on my MacMini, (I just checked it to be 100% sure) I opened seven documents with Recent Docs set to 10 - they were ALL listed. I set it to 1 and all but the most recent cleared. I then closed Reader and reopened it. The list was 1 item. I reset Recent Docs to 10 and there was still only 1 item in the list.

  • How to delete ear file when it is installed as library

    Hi All,
    I have installed one ear file as (library not as application) in WEBLOGIC server but I am not able to delete it as it is not visible in deployment screen.how to locate this file and delete it so that I can install new one .
    Thank
    Sumit
    Edited by: user8687839 on Jan 7, 2010 10:21 PM

    Hi Sumit,
    Option 1). Open Config.xml and delete the Entry for your Shared Library and then Restart the Server.
    Option 2). Use the Following ANT build to undeploy your Application
    http://jaysensharma.wordpress.com/2009/12/19/ant-to-deploy-applications/
    While using this ANT script Just make a small change put library="true"
    <target name=”undeploy”>
    <wldeploy action=”undeploy”
    name=”${deploy.name}”
    failonerror=”false” user=”${wls.username}”
    password=”${wls.password}” verbose=”true”
    adminurl=”t3://${wls.hostname}:${wls.port}”
    targets=”${deploy.target}” library="true" />
    </target>
    Option3). Login to AdminConsole---> Deployments -->Customize this table(Click Here) --->Exclude libraries when displaying deployments (UNCHECK) this checkbox
    Thanks
    Jay SenSharma
    http://jaysensharma.wordpress.com (WebLogic Wonders Are Here)
    Edited by: Jay SenSharma on Jan 8, 2010 5:18 PM

  • In adf,how to delete a file generated on server,when the webpage is closed

    Hi,
    I have an application consisting of 2 pages. in the 1st page i will give some input details and when i click on submit, some java code is getting executed in the back. That java code generates a csv file in the server location. after succesful execution of java code, i was redirected to 2nd page. In 2nd page, i am giving option to download and when the user clicked on download button and after the file is downloaded -- in the backend i am deleting the file from the server. Till this point everything is fine. But if the user didnt click on the Download button and instead if he closes the browser, the csv file gets remained on the server itself. This is the issue i am facing .. I am not able to get an idea in ADF Framework, how to delete a file when the browser is closed. Please help me out in this.
    Thanks in advance !!!

    ADF has nothing to do with tracking browser close buttons. What you can do is call a JS function and call the method which deletes the file from within the JS function. ADF has a component for calling java code from JS call.

  • How to delete  Plugins files in Library

    Hello guys.
    I am using AU plugins called Aalto .I saved files.
    That makes Logic keep crashing.
    So I wanna deleted the files I saved.
    I try to find a folder to removed it but I cound not find it .And try reinstall plugins and loading again but still the files is there. I dont get it.
    Can somebody help that how to delete the file  " Test version recoding ,Welcome to Aalto."?
    Please help.
    Thanks.
    Luna
    CCCcan

    If the cache path is to this folder then go with purging or else stop bi service and delete

  • How to delete temp files in /u99/temp/obiee_tmp

    Hi All,
    We have 50gb on /u99 but it got filled suddenly 35gb. While checking I found that following files are created with 7.1 gb size.
    nQS_7676_24_20578926.TMP
    Can someone please help us how to delete these files.
    1. Will running purge_cache.sh scripts clears these files?
    2. Can we delete these files manually?
    We have Oracle Business Intelligence 10.1.3.4.1
    Thanks in advance.

    If the cache path is to this folder then go with purging or else stop bi service and delete

  • Very Urjent: How to delete temporary files on the server.

    EBS:
    We are facing a big issue with huge volume of temporary directory.We have created invoice program which uses Bursting concept. Every concurrent program is erroring out. How to delete those files automarically.
    Where these temp files are getting stored. How can we delete them once the concurrent request is completed.
    Please help me..its a huge issue. Thanks in advance.

    Sorry Steven,
    I saw your solution. Thanks for that. But I just want to know, do we have any setups in XML Publisher Administrator or bursting control file to delete the files automatically once the concurrent request is completed.
    And one more thing I found is, In the xml administrator, General properties i have specified the temporary directory as '/tmp'. But all the temporary files are loading in '$XDO_TOP/temp' directory. Why is this..

  • How to delete the file with space in name

    Hi
    I want to delete the file "test ex.txt" file.
    i run the following command in command prompt.i can delete the file successfully.
    /bin/rm -f /mnt/"test ex.txt"
    I want to run the command from java.So i am using the following code
    String cmd = "/bin/rm -f /mnt/\"test ex.txt\"";
         Runtime rt = Runtime.getRuntime();
    process = rt.exec(cmd);
    The file was not deleted.
    How to delete the file with space in name?
    Help me

    Use the form of exec that takes an array of command + args.
    arr[0] = "/bin/rm"
    arr[1] = "-f"
    arr[2] = "/home/me/some directory with spaces";Or use ProcessBuilder, which is the preferred replacement for Runtime.exec, and which Runtime.exec calls.

  • How to retreive this file in SQL*Plus

    If I upload files which name is KOREAN, name of files is invisible.
    I dont't know cause of this problem.
    How is keeping korean name of file from breaking?
    Also, answer how to retreive this file in SQL*Plus
    Thanks
    silverbell

    To access ifs data from SQL, you need to (officially) setup a 'user view'. Refer to the Java API documentation on how to do this. Once you have created the user view, then you may access this view using any SQL tool.

Maybe you are looking for