Deleting a file

Hii;
I just want to delete a file from a directory..what should i have to do???
can u else pls tell me....
thanks in adv..

AmitChalwade123456 wrote:
File file = new File("Myfile");
if(file.exists)
file.delete();
}A java.io.File does not have a public attribute called exists .

Similar Messages

  • How to delete when file in use by the finder?

    I have two files in my trash which won't delete. I get the error that they are being used by another program. Holding down option, using secure empty trash, using the terminal method of deleting the trash.. none of them work.
    So I did the terminal command: lsof /path-to-file and found out it was being used by Finder. I don't think I can exactly quit the Finder process in Activity Monitor.. so how can I get these files out of my trash?

    Thanks. Unfortunately, when I quit finder and try to delete the files in the trash by the following command:
    sudo rm -rf ~/.Trash/*
    It tells me "Directory not empty". Argghh..
    I feel like I've tried everything. Can someone give me some other suggestions? Thanks

  • Error while deleting a file which is in a folder which inturn in workspace

    12:20:42.309  DELETE  (FAILED: Conflict [(pre||post)-condition failed: x:concurrency-lock-denied])  Hello.java   (C:\CFolder1\WSF1\WSF2\Dev\HelloWorld\Package\Hello.java)
    --- Problem summary: ---
    12:20:42.309  DELETE  (FAILED: Conflict [(pre||post)-condition failed: x:concurrency-lock-denied])  Hello.java   (C:\CFolder1\WSF1\WSF2\Dev\HelloWorld\Package\Hello.java)
    I am getting above error while deleting a file which is in a folder which inturn in workspace

    Here is the problem I have with deleting my folder. I had created a WD project TaxTool and and added the DC to my SC. There were obviously some checkedout activities. Being new to this, I deleted the project directly without checking in the activities. Now I have folder TaxTool/_comp with nothing underneath on the DTR server and on my client. I am unable to checkout TaxTool for delete but the checkout of _comp folder fails in NWDS with the following error:
    <b>EDIT  (FAILED: server response: Conflict [(pre||post)-condition failed: x:no-exclusivity-with-existing-checked-out-resources])  comp   (C:\JDI\JDIDEMO1\intelJDI_TEST\dev\inactive\DCs\intel.com\TaxTool\_comp\)</b>
    If I try the same from the DTR shell, I get this following error:
    <b>Unexpected problem occurred during executing command.Lockfile "C:\Documents and
    Settings\bvedamur\.dtr\.syncdbs\5b0d8b2110a7a29883734c0407462df8.syncdbM.lock" is already in use by another process.</b>
    I am the only user in the system (doing R&D) and I have tried Sync and Delete. Nothing works. Help appreciated.
    Thx
    Bhaskar

  • When using a Seagate 1T external hard drive and Time Machine to back up hourly, if I delete photo files from the Mac hard drive before the next back up, are these retained on the Seagate drive or will they be lost (overwritten) in the next backu in the ne

    Does Time Machine erase previously saved files if, say, photos are deleted from the Macbook upon the next update, or will they be stored indefinately despite the current status of the files stored on the computer? Eg. can I bckup photo files to a Seagate 1T disc and then delete them to make more room on the computer in the knowlwdge that they are always going to be on the Seagate disc? Sorry if this is very elementary but I have not used a back up before like this, and am not sure how successive backups are overlaid or retained. Thanks!!

    TM is not designed to do what you ask. As Allan wrote TM is an incremental backup not an archival solution.
    If you delete a file from the HD it will eventually be removed from the TM backup (if it ever makes it on to the backup at all).
    How long before it is removed depends on a number of factors, TM disk drive size being one factor but not the only one.
    Material that is impossible to replace and is important to you (image files usually fitting that description) need to be backed up to as least one other drive and preferably more for long term storage.

  • Deleting individual Files from trash folder

    This should be a simple question...Is there a way to permanently delete individual files/folders from the trash folder instead of emptying the entire trash folder? TIA, Scott

    As Allan says, no... the trash *should not* be used as a repository for files you're not sure you want to trash yet. Not only is this extremely hazardous, as it's easy to accidentally empty the trash, but it also puts all those questionable files outside the reach of Time Machine, so they will not be backed up. If you need a "Pending Trash" folder, create one on your desktop, and then put files in the trash only once you are truly ready to delete them.

  • Why does iTunes create disk errors when deleting movie files?

    I use a Macbook Pro, OSX 10.7.5. When I delete movie file from my iTunes library I get disk errors. I need to option boot select the recovery disk and repair the disk.  Deleting a movie file I have placed on my desktop with finder does not create any errors.  Most of the movie files are created as .m4v movies. They all play just fine with my Apple TV. I have tried turning off the Apple TV and rebooting before I delee files but nothing seems to work.
    Any ideas?
    Lance

    If you let iTunes organise your media folders then that is the way it is. An option would be to change the Media Kind to TV Show which would gather them togther in one folder, but in a different part of the library.
    tt2

  • HT2674 I have an iMac purchased in May 2011.  OSX Lion 10.7.3.  I deleted backup file from the external hard drive. Now, the trash can will not empty some of the files deleted.  File folder: "Core Services" contains a locked file: "boot.efi".  It will not

    I have an iMac purchased in May 2011.  OSX Lion 10.7.3.  I deleted backup file from the external hard drive which operates from Time Machine.
    Now, the trash can will not empty some of the files deleted from the backup harddrive.
    The trash contains-- File folder: "Core Services" which contains a locked file: "boot.efi". 
    It will not delete.
    How do I get the trash can empty of these files?

    Yes, the Old Master file has a folder for each year where I find all photos from that specific year. I am attaching a screen shot of the file.
    In the meantime i have managed to download all photos (it did not download any video files though in mpg, avi, 3gp, m4v,mp4 and mov format) to a new iphoto library. Unfortunately the photos are quite mixed and often doubled up. I ma considering to purchase iphoto library which checks all duplicates in iphoto. this will save me a lot of time. What do you think?

  • I have installed itunes 11.0.2.26. When I delete a file or podcast I am not being prompted to delete the file from its folder at the same time.

    I have installed itunes 11.0.2.26. When I delete a file or podcast I am not being prompted to delete the file from its folder at the same time. How do I restore this facility? I am running a 64bit Windows 7 OS

    Is the media files in question in the iTunes library or elsewhere on the computer?

  • If i delete a file from a smart folder is it deleted from the hard drive?

    I've got a late 2011 17" MacBook Pro with a 750 GB harddrive. I'm trying to free up space by deleting movie files. I spoke with tech support about this, and they suggested creating a smart folder of all my movie files in order to find them and delte them. I did this and deleted many files, but when I open system information to check on the amount of hard drive space, I'm still seeing the same amount of hard drive space dedicated to movies.
    If I make a smart folder and delete files in that, am I really deleting them from my hard drive or just from the smart folder?

    What files are stored automatically by Time Machine?  I thought Time Machine pretty much saved everything on my hard drive to my external hard drive.  If that is the case, wouldn't my music files and picture files be on Time Machine (via my external hard drive)?
    Time Machine does backup almost all files on your hard drive, unless you have chosen to exclude them. There are a few exceptions, but nothing you should worry about. Your music and photos should be there, but Time Machine will not backup your iPhoto library if iPhoto is open.
    Also, are the photos from iPhoto automatically stored on my external hard drive via Time Machine?  If so, can I delete the pictures from iPhoto without deleting them from the external hard drive?
    Yes to both questions, with the above cavat that Time Machine won't backup the library if iPhoto is open.
    I notice that it takes iPhoto quite a while to load, and if deleting those photos would allow it to load quicker I would delete them (providing they would remain on the external hard drive.
    I only have a few pictures in iPhoto, compared to my wife's 3,500+, and my iPhoto doesn't load appreciably faster that her's does even though I have a faster computer. In my opinion, it isn't worth the effort it would take to delete them for such a small gain.
    You should have at least 2 complete backups to try to make sure you won't lose any data. Hard drives do fail and/or files can become corrupted. Time Machine can back up to more than one external hard drive or you can use a cloning program.
    Time Machine FAQ

  • HT203200 Cannot delete the file from the itunes folder

    I cannont delete the file from the itunes folder because it tells me I need permission to do so.  I am the admin person for the laptop plus I have checked my permissions under the security tab in the files properties.  How do I delete this file to start again?  It downloaded 1.2GB of the file before the error message appeared, so its paid for and all but not looking like I'll get to watch it before the time runs out on the movie being available for me to watch. :-(

    Try deleting the file without iTunes running.
    When you next open iTunes it should then be marked as a missing file and you should be able to delete the entry from iTunes.
    Hope this works
    Regards,
    Colin R.

  • I cannot delete a file from the document folder.  I can move it to the trash and then empty the trash, but when I go back to the documents folder it is still there.

    I cannot delete a file from the documents folder.  I can move it to the trash and then empty it, but when I go back to the documents folder, the file is still there.

    Gay,
    I wonder what your computing environment is. Is your account being administrated by another account? Are you working in an account subject to "Parental Controls"?
    Jerry

  • Delete PDF file from a folder

    Hi!
    please help me this is urgent..
    i try to delete pdf file from my local pc how to do that ??
    can some one help me i need it by today please help me ..
    thanks to all of you...
    from:
    newbie

    First you open a File to the specified file, and then you call delete(). Easy
    File file = new File("path/filename");
    file.delete();Of course if you want to make your application cross-platform you will need to build a correct path somehow. Check out the static attributes of the File class to help you (fx. File.separator).

  • Why can't I delete the file?

    What I want to do is: After user download the file from web, the application will delete the file automatically on ther server. However, the delete function cannot work which it prompts the java.lang.Exception, I suspent it is the download process hold the file, how can I solve it?
    DownloadReport(request, response, reportFile);
    Utility.deleteFile(reportFile);
         public void DownloadReport(HttpServletRequest request,
                   HttpServletResponse response, String reportFile) throws Exception {
              File fFile = new File(reportFile);
              String stFileName = fFile.getName();
              response.setContentType("application/vnd.ms-excel");
              response.setHeader("Content-Disposition", "attachment;filename=\""
                        + stFileName + "\"");
              // System.out.println("Henry "+getServletContext());
              InputStream isStream = null;
              try {
                   PrintWriter out = response.getWriter();
                   isStream = new FileInputStream(fFile);
                   int i;
                   while ((i = isStream.read()) != -1) {
                        out.write(i);
                   isStream.close();
                   out.close();
              } catch (Exception ioeException) {
                   log.error("Download report error", ioeException);
                   ioeException.printStackTrace();
                   throw new ServletException("Download report error", ioeException);
         public static void deleteFile(String path) {
              boolean deleted = false;
              try {
                   File delefile = new File(path);
                   if (delefile.exists())
                        deleted = delefile.delete();
                   if (deleted == false)
                        throw new Exception("File could not be deleted " + path);
              } catch (Exception e) {
                   e.printStackTrace();
         }

    Hi, my application is using POI API generating the Excel report, after genration, the report will be stored on the server, and then user download the report to their local machine throught web and then I delete the report on the server. I don't quitely understand what you mean, could you kindly explain to me detailly:p. Btw, I have tried to print out the exception, but it only shows "java.lang.Exception: File could not be deleted " which is so limited. If I comment the DownReport function, the file could be deleted successfully. But if it happens after the download action, it is failed.

  • System exception while deleting the file from app server in background job

    Hi All,
    I have a issue while the deleting the file from application server.
    I am using the statement DELETE DATASET in my program to delete the file from app server.
    I am able to delete the file from the app server when i run the program from app server.
    When i run the same report from background job i am getting the message called System exception.
    Is there any secuirity which i need to get the issue.
    Thank You,
    Taragini

    Hi All,
    I get all the authorization sto delete the file from application serever.
    Thing is i am able to run the program sucessfully in foreground but not in the background .
    It i snot giving any short dump also just JOB is cancelled with the exception 'Job cancelled after system exception ERROR_MESSAGE'.
    Can anybody please give me suggestion
    Thanks,
    Taragini

  • Help needed - OS Command foe deleting a file from Appplication server.

    Hi,
    I have requirement, where in i need to delete a file from the application server. It has to be done automatically. I thought of using OS Command for achieving the same. Can anyone help me in achieving it. The OS of my application server system is UNIX.
    Thanks in advance!!
    P.S: Points will be rewarded.

    Hello Sudeep,
    If you define the command for each operating system using transactions SM69 (You can test it with SM49) and then call it using SXPG_COMMAND_EXECUTE which contains a parameter defining the operating system (SY-OPSYS)
    then it does not matter which operating system is running, the function module always calls the correct version of the command.
    So, for example you could define a command 'OS_COMMAND'
    which deleted a file. This would have one version for Dos
    which said 'del', and a second version for unix which said 'rm'.
    The correct command would be specified by the call to SXPG_COMMAND_EXECUTE because the operating system parameter differentiates between the two commands.
    [USING PROCESS CHAINS IN SAP BW|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e0a7cd90-0201-0010-49a1-d730a56895f4]
    SXPG_COMMAND_LIST_GET – Reads a list of external OS commands
    Thanks
    Chandran

  • How to delete a file from Appliction Server.

    Hi Gurus,
    I want to delete a file from application server .
    can any one tell me the FM/BAPI.
    Plz Reply me ASAP.
    Thanks in Advance.

    BAPI_DOCUMENT_DELETE ?
    GUI_DELETE_FILE ?
    maybe just go to SE37, enter DELETE, and click on the document icon to find from repository system.
    Regards,
    Vincent

Maybe you are looking for