Problem In Deleting file

When I call fileone.exists()
It is returning true.
But I am unable to delete file even after calling fileone.delete();
There are some tabs in Swings. From deletion tab I am trying to delete. But I am unable to delete.
I tried to delete the same file from a simple Java file I am able to delete it.
Is there any lock preventing me from deleting the file ?
Any help is appreciated.............

As you can see in many threads, people talks about a bug in some JVM implementations preventing files to be deleted even if you have closed any stream related to it. I tried many times to delete files to no success until I read some posts advising to use the System.gc() method to destroy any object previously closed (but presumably still existing).
I tried
System.gc();
for(File iterator: arrayOfFiles)
iterator.delete();
but the result I obtained wasn't totally satisfactory, because the first files from the array of files weren't delete while the last ones were. So I thought that maybe the problem is the garbage collector had no time to "act" before the first files were deleted. My (not quite elegant, but effective) solution was to introduce a delay of 500ms between the garbage collector request and the first delete statement. I know you have no warranty about the garbage collector acting when you ask it to, but... Anyway, this is my code:
System.gc();
Thread.sleep(500); // delay to allow the garbage collector to do its work before any deletion is attempted
for(File iterator: arrayOfFiles)
iterator.delete();
As I could see, it works 100% the times I tested it.
I don't know if this "solution" was mentioned before or not but, in either case, I hope this helps someone.
Regards

Similar Messages

  • Hi, the problem of deleting files / videos seeds desktop to go into Terminal and then sudo rm-rf ~ /. Trash Pohangina the answers I've had e of someone in her forum but when I write procedures line in Terminal as the Krever my password and it can not writ

    Hi, the problem of deleting files / videos seeds desktop to go into Terminal and then sudo rm-rf ~ /. Trash Pohangina the answers I've had e of someone in her forum but when I write procedures line in Terminal as the Krever my password and it can not write anything there, I write but nothing comes and my problem is not löst.När I want to delete the movie / video image Frin desktop still arrive Finder wants to make changes.Type your password to allow this. But even that I type my password file / video is left I need help in an easier way or another set-even those on the terminal that I can not type my password to solve the problem Regards Toni

    If you want to preserve the data on the boot drive, you must try to back up now, before you do anything else.
    There are several ways to back up a Mac that isn't fully working. You need an external hard drive to hold the backup data.
    1. Boot from the Recovery partition or from a local Time Machine backup volume (option key at startup.) Launch Disk Utility and follow the instructions in this support article, under “Instructions for backing up to an external hard disk via Disk Utility.”
    2. If you have access to a working Mac, and both it and the non-working Mac have FireWire or Thunderbolt ports, boot the non-working Mac in target disk mode. Use the working Mac to copy the data to another drive. This technique won't work with USB, Ethernet, Wi-Fi, or Bluetooth.
    3. If the internal drive of the non-working Mac is user-replaceable, remove it and mount it in an external enclosure or drive dock. Use another Mac to copy the data.

  • Toshiba Gigastore 250 GB: Problems to delete files

    Dear all,
    I can't delete files from my Toshiba Gigastore anymore. Every time I try, the following message appears: "Cannot delete. Access denied. Source is probably still open".
    However, the files are not in use when I try to delete. I tried to delete after a reboot, and tried as admin. Nothing works.
    The problem started to occur after the Gigastore got disconnected from the computer (hot plugout).
    My OS is W2K SP4 (with the latest security updates). The GigaStore didn't run properly from the beginning, as it is not possible to disconnet the USB when the system is running (this problem is known and described in the user manual).
    Howe can I overcome the problem without reformatting the drive? Maybe it is possible to boot linux and delete files on the GigaStore? Is that advisable, as linux doesn't seem to go along well with NTFS?
    Many thanks in advance,
    Led
    Keywords: Toshiba Multi Media Center Gigastore 250 GB, delete, file in use, Windows 2000 SP4

    Hello,
    many thanks for your advice. The issue is solved now.
    Going through your replies, I investigated why the files could not be deleted. I found that something happened with my user rights since the hot plugout: The system just 'took' the 'write' rights from existing files. However, I was able to read and execute existing files, and write _new_ files.
    A subsequent login as Admin with re-assignment of 'write' rights worked fine. (However, I am sure that I have tried this earlier, but it did not work at the time).
    Again, many thanks for your help. Best regards,
    Led

  • Problem with deleting files !!

    I want to delete file, but for some extensions it is not possible, how can I delete all files?
    I use
    myFile.delete();

    How about the return value from your delete call, is it "true"? What happens when you try to delete the file via your OS? Why do you seem to think that this behavior is specific to certain file extensions? Which extensions are you having trouble with?
    Sorry for all the questions. Just as a guess, I think the most common reason for a delete call not to work on a Windows box is because the file is in use by some other program - an editor, or maybe a web server. Trying to delete the file via the OS might give you a better idea of why it's not deleting.
    good luck
    Lee

  • Problems with deleting files to the trash

    I cant delet files to the trash. The only option is to delet permanently.
    "The file wil be deleted immediately, are you shure you want to proceed?"
    (bad translation from norwegian)
    can anyone please help me?
    -w-

    W, Welcome to Apple Discussions.
    Choose your Home folder and "Get Info" (command-i). Under "Ownership & Permissions" be sure you have "Read & Write" privileges. Under "Details", be sure you are the owner.
    -mj
    [email protected]

  • Restored from Time Machine and now having problems when deleting files..

    I recently had to restore from a Time Machine Backup on my Macbook Pro 7,1 (2.66Ghz, 8GB Ram) ... and now, I've noticed that when I delete files from my laptop, they're not going to the trash bin, they're just "gone" ... the trash bin stays empty.  Any ideas how to fix this?

    Select the icon of your home folder in the sidebar of a Finder window, and open the Info window. In the Sharing & Permissions section, click the lock icon and authenticate. Delete all permssion entries except read & write access for you. From the action menu (gear icon), select "Apply to enclosed items." Close the Info window and try again.

  • Problems with deleting files i have tried all  please help

    my problem is I already delete all the files form my ipod mini and reset it several times the problem is the ipod mini is a 4GB but I have no files on it a my free space is of 2.3GB and I don't know what to do so I can use all the memory again because I already delete everything and still the memory acts like if there was music or files on it.
    help please

    gustavo,
    Restore the iPod to factory settings.

  • Problem moving/deleting files from time machine backup

    I recently ran into some problems with my hardrive and had to get it replaced at the mac store.
    Unfortunatly, i only ran a partial time machine backup on the hardrive before i lost it.
    Fotrunatly though, it did manage to save some important stuff, but now for the next problem....
    I have dragged my files from my external hardrive with the partial time machine backup onto my new desktop but it wont let me do stuff with them
    this includes;
    asking for my password whenever i want to delete one of them
    saying "cannnot be modified" whenever i try to drag the files to a new location.
    as you can imagine, this is a bit of a pain.
    anyone have anything similair?
    help would be great
    thanks
    Chris

    That is not how you restore from a Time Machine backup.
    Repairing the permissions of a home folder in Lion is a complicated procedure. I don’t know of a simpler one that always works.
    Back up all data now. Before proceeding, you must be sure you can restore your system to its present state
    Launch the Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the page that opens.
    Drag or copy — do not type — the following line into the Terminal window, then press return:
    chmod -R -N ~
    The command will take a noticeable amount of time to run. When a new line ending in a dollar sign ($) appears below what you entered, it’s done. You may see a few error messages about an “invalid argument” while the command is running. You can ignore those. If you get an error message with the words “Permission denied,” enter this:
    sudo !!
    You'll be prompted for your login password, which won't be displayed when you type it. You may get a one-time warning not to screw up.
    Next, boot from your recovery partition by holding down the key combination command-R at startup. Release the keys when you see a gray screen with a spinning dial.
    When the recovery desktop appears, select Utilities ▹ Terminal from the menu bar.
    In the Terminal window, enter “resetpassword” (without the quotes) and press return. A Reset Password window opens. You’re not going to reset the password.
    Select your boot volume if not already selected.
    Select your username from the menu labeled Select the user account if not already selected.
    Under Reset Home Directory Permissions and ACLs, click the Reset button.
    Select  ▹ Restart from the menu bar.

  • Problem with deleting files from new Zen St

    I recently bought a Zen Stone and today needed to delete some files. Did this from Windows (like with my Zen Nano), but this did not free any space on the Stone.
    Went to browse files (albums) on Stone and found several names that did not show up in either a Windows Explorer or Media Lite search.
    Apparently when I deleted the old files, they did not actually get deleted (guess I have to use Media Lite to do this)
    Any suggestions as to how to remove these files without reformatting?

    Hi,
    Do you expect anyone to read that? Please use code formatting when you post code. See the formatting tips:
    http://forum.java.sun.com/help.jspa?sec=formatting
    Kaj

  • Problem of Delete and Overwrite XLS file on Application Server

    Hi Experts,
         I want to transfer file on application server using below code and try to delete after successfully transfer on application file to other location.
    I have problem during deleting file and overwrite file.
    DATA: G_S_FILE TYPE EPSFILNAM,
          G_S_DIR  TYPE EPSDIRNAM,
          G_T_FILE TYPE EPSFILNAM,
          G_T_DIR  TYPE EPSDIRNAM.
    DATA : DELFILE(60).
      G_S_FILE = '1400000051.XLS'.
      G_S_DIR  = '\\Dev\PO\'.
      G_T_FILE = '1400000051.XLS'.
      G_T_DIR  = '\\Dev\PO\bkup'.
      DELFILE = '\\Dev\PO\1400000051.XLS'.
      CALL METHOD CL_CTS_LANGUAGE_FILE_IO=>COPY_FILES_LOCAL
        EXPORTING
          IM_SOURCE_FILE           = G_S_FILE
          IM_SOURCE_DIRECTORY      = G_S_DIR
          IM_TARGET_FILE           = G_T_FILE
          IM_TARGET_DIRECTORY      = G_T_DIR
          IM_OVERWRITE_MODE        = 'S'
        EXCEPTIONS
          OPEN_INPUT_FILE_FAILED   = 1
          OPEN_OUTPUT_FILE_FAILED  = 2
          WRITE_BLOCK_FAILED       = 3
          READ_BLOCK_FAILED        = 4
          CLOSE_OUTPUT_FILE_FAILED = 5
          OTHERS                   = 6.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      OPEN DATASET DELFILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      IF SY-SUBRC = 0.
        DELETE DATASET DELFILE.
      ELSE.
        WRITE / 'File not found'.
      ENDIF.
    Thanks,
    Himanshu Patel.

    Write a Java program using Apache POI that reads in a tab delimited file and outputs an xls file (in what they call Horrible Spread Sheet Format. Create your tab delimited file and then run your Java program using appropriate OS commands.
    Jelena Perfiljeva wrote:
    In all honesty, I find it hard to believe other application can't accept any other format. It's actually seems rather unreasonable to expect an ERP system to create a file in an outdated format of a desktop software. Even Excel itself can open many formats, so this just doesn't make any sense.
    This.
    Unless you can explain exactly why the destination must be xls and no other format is acceptable, I'm going to close the thread. What is this third party tool? Why can it only read the obsolete xls file format.
    I'm going through this thread and rejecting all the responses that attempt a solution that isn't xls.
    I'm surprised that the OP thought that simply saving with an xls file extension would cause some magic to happen and produce an actual Excel file.

  • Roaming User sync does not work and/or deleted files on desktop restored.

    Hello
    We have a customer with MBP's and a Server 10.6. At the MBP is a local Admin Account configured and all the employees have roaming profiles.
    Sometimes we have the problem that deleted files and folders at a Desktop will be restored after relogin AND it seems that some Adobe Products prevent syncing sometimes if files at Desktop opened.
    Is there any solution for that?

    Same issue here.
    I have BB 9700 and Yahoo! BIS account.  Worked like a charm until about a week ago.
    It was even synchronizing my calendar and mail between BB and Outlook 2010 - never really understood how it managed to do that, but I was very pleased.
    As of lately our telecom administrator spent hours on the phone with AT&T, Yahoo and RIM trying to resolve this problem.  I was told by RIM tech. support that I've got too many messages in the inbox (measly 5000 e-mails) and that BB stops synchronizing after about 800 messages in the inbox, because it is timing out with so many messages to go through.  Sounded like a total BS to me, but I still went ahead and cleaned up my Yahoo inbox and no luck, as I suspected.  I was also told by tech. support that it is due to my using Outlook 2010 Beta2, which is not supported, hence the issue - another ferry tale, IMHO.
    Hopefully, RIM will be able to get us back on track - manually deleting 60 emails every day is extremely annoying.

  • I am deleting files through my trash in my macbook pro (2010) and then emptying the trash can, but my hard disk space is not increasing! i recently upgraded to lion and the problem is new, wasn't the same with snow leopard! HELP!!!!!

    i am deleting files through my trash in my macbook pro (2010) and then emptying the trash can, but my hard disk space is not increasing! i recently upgraded to lion and the problem is new, wasn't the same with snow leopard! HELP!!!!!
    When i press command+I (Get Info) i see that there is 140 GB "Available Space" on my hard disk but when i click on my hard disk icon on the desktop, and then press "space" i only see 102 GB free!! What the f*???
    Please HELP!!!!!! Getting second thoughts on Lion!!!!

    Hi b,
    Have you restarted yet?

  • Problem with deletion of files

    hi
    i have a very strange problem, so the application is swing app, i use intellij IDEA this is only informative.It is for uploading files to ftp, at the end of the process i must delete files, the problem is that the last one file doesn't delete.The strange is that when i run the application from idea it works ok, but when i run the application from jar it can't delete the last file
    i make jar file with ant. the difference between the running application from idea and from the jar is that in idea i create instance of Login (JFrame) and it is on, from the jar there is a method that at run time execute the following command in a new thread : "java -Xms128M -Xmx512M"
    + " -cp ./;ProcessingTool.jar; + "(here is adding all libs to class path...)"
    + " dialogs.Login");
    i thought that i have not close a stream, but why then from idea it works, and from jar doesn't.
    please help!!!

    i have used adobe reader 8 and now 9. However, i am having trouble opening form files from http://www.mca.gov.in which is a government site.
    the error i get is "this document enabled extended features in adobe reader. the document has been changed since it was created and use of extended featuresis no longer available. Please contact the author for the original version of this document."
    please help as i am able to open these files on another computer running older adobe reader version
    thanks in advance
    regards,
    ashish ahuja

  • [solved] Problem with ssd disk, deleted files don't free space?

    Hello.
    I bought some time ago an ssd disk on which i installed arch. After some free time I changed my laptop optical drive with standard hdd and moved /home and folder with data (mainly music collection) to standard drive. To my surprise my ssd was filled as it were before. My fstab from beginning have had TRIM option enabled:
    LABEL=root / ext4 rw,noatime,discard,commit=600,barrier=0 0 1
    tmpfs /var/log tmpfs defaults,size=5% 0 0
    tmpfs /var/spool tmpfs defaults,size=5% 0 0
    LABEL=karta /run/media/kaira/karta/ ext4 rw,noatime,barrier=0,commit=600,data=writeback 0 1
    LABEL=home /home ext4 rw,noatime,barrier=0,commit=600,data=writeback 0 1
    LABEL=dane /dane/ ext4 rw,noatime,barrier=0,commit=600,data=writeback 0 1
    where the last three lines were added after second disk was installed.
    And now the great mystery for me:
    du -h / |sort -h -r|head -n 5:
    3,7G /
    2,7G /usr
    1,6G /usr/lib
    845M /usr/share
    771M /var
    df:
    System plików rozm. użyte dost. %uż. zamont. na
    /dev/sdb1 118G 27G 90G 24% /
    devtmpfs 3,8G 0 3,8G 0% /dev
    tmpfs 3,8G 1,4M 3,8G 1% /dev/shm
    tmpfs 3,8G 4,0M 3,8G 1% /run
    tmpfs 3,8G 0 3,8G 0% /sys/fs/cgroup
    tmpfs 3,8G 13M 3,8G 1% /tmp
    tmpfs 389M 32K 389M 1% /var/log
    tmpfs 389M 0 389M 0% /var/spool
    /dev/sda1 50G 241M 49G 1% /home
    /dev/sdc1 30G 45M 29G 1% /run/media/kaira/karta
    27G was the state before most data was transfered to different hard drive.
    Both commands where executed after partition with music was unmounted.
    I executed also fstrim / command, but it changed nothing.
    Is this behavior normal, or maybe i didn't made something important/ my disk is damaged?
    I know that 24% fulfillment is trivial, but now it definitely should show 3,5%.
    Last edited by kaira (2013-11-01 19:45:31)

    Yes, I run this command as a root. I manage to repair this problem by mounting root partition in ubuntu live cd. I found folder which should get deleted, but it still was in filesystem. Unfortunetly I don't remeber, how i copy files. Propably i used rsync and forget to delete files. Now it's too late too check this theory, but I'm really happy with proper sizes:
    Filesystem Size Used Avail Use% Mounted on
    /dev/sdb1 118G 3.6G 113G 4% /
    devtmpfs 3.8G 0 3.8G 0% /dev
    tmpfs 3.8G 6.0M 3.8G 1% /dev/shm
    tmpfs 3.8G 3.9M 3.8G 1% /run
    tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup
    tmpfs 3.8G 356K 3.8G 1% /tmp
    tmpfs 389M 0 389M 0% /var/spool
    tmpfs 389M 32K 389M 1% /var/log
    /dev/sda2 410G 25G 381G 7% /dane
    Lesson learned - never manage important system changes after getting up, without enough sleep time.
    Thank you for you're help, and sorry for wasting time with my mistakes.

  • Problems to delete big *.tif files

    I have problems to delete big *.tif filese.
    At first Windows delete it, but if i pressed F5 then the files are not deleted. I have tryed to delete it with and without Shift + Del its always the same.
    When i delete this file many times then it would be deleted.
    A other Problem with this big files is that windows open a dialogbox and calculate the time that needed to delete the tif file.
    But i can wait 2 hours and more, nothing is done by windows. In the dialogbox dosn`t change anything.
    Have anyone an Idea?
    Thank you in advanced.
    Daniel

    Hi,
    Does it happen to other files, just *.tif files? Generally speaking, When deleting a folder, the calculation time depends on not only the
    file size but the file numbers of the folder. So you can delete sub-folders separately.
    Also, you can try to use a popular methods to fix the issue. Here is the steps:
       1.  Right click on the file. 
       2.  Click Properties
       3.  Click
    Advanced
       4.  Under File Attributes uncheck
    Allow this file to have contents indexed in addition to file.
    Also, you can take the following steps to fix this issue:
    Step 1:
    You may try creating a new user profile to see if the same problem occurs. If not then it could be a corruption/permissions problem
    of the old user profile.
    To create a new user account
    http://windows.microsoft.com/en-us/Windows7/Create-a-user-account
    Step 2:
    If the new user account works fine then the previous account was corrupt, you may follow the link given below to fix the corrupt
    user profile.
    Fix a corrupted user profile
    http://windows.microsoft.com/en-US/Windows7/Fix-a-corrupted-user-profile
    In addition, the issue can be related to third-party components, especially file system filter drivers, such as anti-virus drivers. In this situation,
    I suggest you can delete the files on Safe Mode. If on Safe Mode It works fine, you could perform
    clean boot to check the result.
    Hope it helps.
    Regards,
    Alex Zhao
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

Maybe you are looking for

  • Can anyone tell me how to stop boxes from popping up asking for my family members apple id?

    Please help!!  Pop ups on my Iphone 5 driving me nuts!!

  • B2B Help to do following setup : Message from EBS to BPEL to B2B to TP

    I created a BPEL to send message to B2B and it works. BPEL send message to B2B. Identifies Agreement and etc. Message have to hit TP using HTTP Post. TP uses port 443. In the trading partner setup I tried different channel I get following message whe

  • Acrobat 7 Script Needed

    I have looked everywhere for help to no avail. Can this be done and if so how? I will have a folder on my desktop. PDFs will be dropped into it. I need a script that will open those files and apply the "Enable Commenting" feature that is in Acrobat 7

  • Load an external html page

    Hello, I tried to load an external html page inside the ide but not found the method. If I right click on my project name present in the Project Navigator I can choose the 'New' voice that leave me the possibilities to only load template pages. Is th

  • I need to create this effect in PS CS3

    It is not a drop shadow as I tried that . All I know is how to use the rectangular marquee to get the rounded corners. What is the correct term for this effect. effect around ring is here http://dagwaremedia.com/pshopeffect.jpg