File/Folder Deletion is not working

Hi People,
I have the following simple POJO class in which I am trying to delete a file but its not happening can someone pls help me on this.
import java.io.*;
class ListFiles
public static void main(String args[]){
String path="C:/Documents and Settings/Desktop//Art/Notes";
File test1 = new File(path);
String[] children = test1.list();
    if (children == null) {
        // Either dir does not exist or is not a directory
          System.out.println("dir empty:");
    } else {
        for (int i=0; i<children.length; i++)
            // Get filename of file or directory
            String filename = children;
          if(!filename.matches("Thumbs.DB")){
          System.out.println("filename:"+filename);
if(test1.isDirectory()){
System.out.println("filename:");
boolean delete_dir=test1.delete();
System.out.println("delete_dir:"+delete_dir);
Thanks,
R.Ramesh.

I tried it ,
pls go thru the following change in my code
import java.io.*;
class ListFiles
public static void main(String args[])
     String path="C:/Documents and Settings/Desktop/IPLIT/Art/Notes";
     File test1 = new File(path);
     String[] children = test1.list();
         if (children == null) {
          boolean delete_dir=test1.delete();
          System.out.println("delete_dir:"+delete_dir);
          System.out.println("dir empty:");
     else {
             for (int i=0; i<children.length; i++)
                      String filename = children;
                    if(!filename.matches("Thumbs.DB")){
                    File test2 = new File(path);
I checked the folder its empty but still its not getting deleted
Message was edited by:
rameshr

Similar Messages

  • Windows XP file/folder handling does not work? (RSP Rules!)

    Sorry if this has been asked many times before, but a forum search on "folder" does not return anything ??? (amazing)
    I am trying to make sense out of where and when to use folders and collections and I wish there would be more info in the help/manual.
    Lesson learned so far: you can spend an awful lot of time flagging images as rejected and then delete them from a quick collection, only to find out that they are only removed from the (logical) quick collection, not from the (physical) folder on the file system. @!x$
    Now, it seams that any folder action does either not work at all or only works partially:
    - I cannot import an empty folder, to put images in later
    - I cannot drag and drop more than one file at a time to a folder
    - When I create a new folder, I never get to see it or name it in Lightroom. It gets created on the file system however, as "new folder (x)".
    Why are there no settings under "preference" where to put libraries, back-ups of libraries, which library to use at startup, where and how to create/store previews and their lifetime and so on?
    Also, there should be a much more convenient way in the handling of multiple computers and creating/restoring backups!
    Reading some of the endless complaints about file corruptions and file losses, I think I will return to RawShooter Premium untill I finally get the feeling that my images and the work on them are safe within Lightroom. RSP is also WAY more snappy and responsive (except for the slide show)!

    Jeff: You truly offered some amazing insight here! I really thought that Adobe bought Pixmantec for their technology and for the wizzards that drove that technology. Now you made it clear that all that is limited to "inspiration". Wow! So, why DID Adobe buy Pixmantec? Market share? Take the most brilliant and cheap competitor off the market? Some other reason???
    Apart from that: I DO know that writing software is not easy. It must be really unpleasant for the hard working "scary brilliant" experts with a serious track history to hear people complain about issues like file handling on a particular operating system instead of admiring their brilliant ideas and concepts.
    Alas, this is life: if you would buy a car you would bring it back to the garage to complain about the lock in the trunk that opens at awkward times leading you to loose your groceries instead of talking to those people about how magnificent that particular car takes you trough corners at 100 mph.
    And I still believe that the RSP folks did a better job with their version 1 than Adobe did with LR, knowing that Lightroom is more complicated than RSP and taking into consideration that the Adobe people have a much longer history and experience with Photoshop/Album/Bridge. So I would say Adobe can learn a lot from the RSP boys. Just do it!
    Tim: as I'm planning to move from RSP to LR (maybe wait until 1.1), the most important starting information I'm looking for right now is how to set up my filesystem and the LR database for the most efficient way of working and for the "most" data security. Neither the LuLa tutorial nor the help file/manual seem to offer much information on this -I believe extremely important- topic.
    All this aside from what seems like Windows file handling bugs to me, hopefully adressed in version 1.1

  • File/Folder delete directly not goto trash?

    Hi all
    when ever i delete any file or folder system ask me to immedate delete the stuff, it doesn;t goto trash.
    Plz help
    Negi
    E-Mac,10.4,512MB RAM

    Hi Negi, Have you seen Dr. Smoke's solving trash problems FAQ?
    -mj
    [email protected]

  • Whenever i try to download a rather large file i continue to get the "could not read source file" error. Tried new profile, uninstalling and looking for the compreg.dat file to delete nothing is working. Please help

    whenever i try to download a rather large file i continue to get the "could not read source file" error. Tried new profile, uninstalling and looking for the compreg.dat file to delete nothing is working. Please help

    Did you reinstall CS3 after CC?
    For that matter, doing an in-place upgrade on the OS is always a gamble with Adobe programs. Reinstalling all the versions you need, in order, would probably solve your problem.
    And you shouldn't need to save as IDML after opening the .inx in CC.

  • I have a MacBook Air using Maverick. I have files in the trash I want to recover. I do not have "Put Back" and Command   Delete does not work.

    I have a MacBook Air using Maverick. I have files in the trash I want to recover to their original files. I do not have "Back Up" and "Command + Delete" does not work.

    Drag them out of the Trash and put them in their original location. Put Back may work on one file at a time.

  • HT1338 Application "FINDER"not responding,Desktop files disappeared & " also "Trash" not working svn after relaunching several times.

    Application "FINDER"not responding,Desktop files disappeared & " also "Trash" not working svn after relaunching several times.

    Launch the Console 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 Console in the icon grid.
    Step 1
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left.
    Enter the name of the crashed application or process (Finder) in the Filter text field. Post the messages from the time of the last crash, if any — the text, please, not a screenshot. 
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into a message.
    Important: Some private information, such as your name, may appear in the log. Edit it out by search-and-replace in a text editor before posting.
    Step 2
    Still in the Console window, look under User Diagnostic Reports for crash reports related to the process. The report name starts with the name of the crashed process, and ends with ".crash". Select the most recent report and post the entire contents — again, the text, not a screenshot. In the interest of privacy, I suggest that, before posting, you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if it’s present (it may not be.) Please don’t post shutdownStall, spin, or hang logs — they're very long and not helpful.

  • Ipad i have load swf file but swf  is not working proper(flex 4.6) but android is fine to work how

    ipad i have load swf file but swf  is not working proper(flex 4.6) but android is fine to work how

    On the MBP, in iTunes, switch to Song view and enable the iCloud Status column by pulling down View > View options and selecting the option for "iCloud Status." Close the small window. Look for any tracks that have a status of "waiting." If you see several of them disable iTunes Match while holding down the Option key. Quit iTunes, wait a few seconds, then open it again and turn iTM back on. Let it compelete the scan. Wait until all tracks that are "waiting" have a status of either "matched" or "uploaded."
    On the iPad, turn off iTunes Match then launch the Music app and let the contents clear out. Power cycle the iPad for good measure, then re-enable the service once all the tracks in iTunes have been processed.

  • File type associations is not working in the App-V 4.6 SP3

    Hello,
    I found issue, that file type associations is not working in App-V 4.6 SP3. When I try to open associated file with double click I receive next window:
    Translate: This action is only valid for products that are currently installed.
    I have checked associations in App-V Console and in OSD file, everything looks like OK.
    Maybe someone has some ideas?
    Could you please share them with me?
    Thank you in advance.

    Is this only happening on one client machine? If so can you completely clear the application and re-stream\cache it again?
    If that fails, you could try to create the FTA locally on the client
    PLEASE MARK ANY ANSWERS TO HELP OTHERS Blog:
    rorymon.com Twitter: @Rorymon

  • In iTunes 11.1 (I26) , I cannot find how to delete podcast listings showing undownloaded podcasts. Delete does not work. Option Delete does not work.  Dragging to the trash does not work. Under Edit, Delete is greyed out. Mac OS 10.6.8

    in iTunes 11.1 (I26) , I cannot find how to delete podcast listings showing undownloaded podcasts. Delete does not work. Option Delete does not work. Dragging to the trash does not work. Under Edit, Delete is greyed out. Mac OS 10.6.8.
    Tom at the Genius Bar told me that Option Delete would work. It does not.
    I had to upgrade to iTunes 11.1.(I26) because it is required with OS7 on my iPod Touch (5th Gen). I have tried shutting down iTunes, then shutting down the entire system. This is the first in many visits that the Genius Bar gave me a solution that did not work.
    This is a big awkward computer locked to my desk. I would rather not unlock it and then carry it through a shopping center to the Genius Bar if i can avoid oit.
    When I installed iTunes 11.1, I discovered that Ihad to resubscribe to virtually all of the podcasts that I had previously been subscribed to. That was a surprise.

    Hello Achates:
    I did not read the rather long post. If you wish to reinstall OS X 10.4, use your software install DVD. Backup is essential. To minimize your risk, I would use an archive and install:
    http://docs.info.apple.com/article.html?artnum=107120
    In that way, you will have a fresh copy of OS X and your current settings will be preserved.
    Incidentally, I do not agree that the printer problem is best solved by reinstalling OS X. I have had HP printers for sometime and, on one occasion, had difficulty after an upgrade. HP technical support walked me through uninstalling all traces of the HP driver and then reinstalling.
    Barry

  • Other database delete is not working on forall statement

    Dear all,
    My scenario is , i create a program, the program fetch the data from database x and i want to delete on the same x database but i am running this program at y database, so
    so i created a view
    create or replace view vw_ibs_pda_bills_x as
    SELECT *
            FROM ibs_pda_bills_x@testarch1my program
    Declare
          CURSOR c2 IS
          SELECT *
            FROM vw_ibs_pda_bills_x
           WHERE bill_month <= '31-dec-2008'; -- AND bpref_no = :cons;
           opr varchar2(10) := 'DELETE';
          TYPE tsch IS TABLE OF c2%ROWTYPE;
          vtsch      tsch;
          cnt        NUMBER := 0;
          stime      NUMBER;
          etime      NUMBER;
          DURATION   NUMBER;
          rcount     NUMBER;
          errorsd   PLS_INTEGER;
          ecode     NUMBER;
          val1   VARCHAR2 (100);
          val2   VARCHAR2 (100);
          val3   VARCHAR2 (100);
          val4   VARCHAR2 (100);
       BEGIN
          BEGIN
             stime := DBMS_UTILITY.get_time ();
             OPEN c2;
             LOOP
                FETCH c2
                BULK COLLECT INTO vtsch LIMIT 1000;
                IF vtsch.COUNT = 1000
                THEN
                   cnt := cnt + 1;
                END IF;
            If opr = 'INSERT' Then
                    FORALL i IN 1 .. vtsch.COUNT SAVE EXCEPTIONS
                          INSERT INTO dlul.ibs_pda_bills
                        VALUES vtsch (i);
            Else
                    FORALL i IN 1 .. vtsch.COUNT SAVE EXCEPTIONS
                        Delete from vw_ibs_pda_bills_x where bill_month = vtsch(i).bill_month;
            End if;
                EXIT WHEN c2%NOTFOUND;
             END LOOP;
             etime := DBMS_UTILITY.get_time ();
             DURATION := ((etime - stime) / 100) / 60;
             rcount :=
                 (cnt * 1000) + vtsch.COUNT - NVL (SQL%BULK_EXCEPTIONS.COUNT, 0);
         If opr = 'INSERT' Then
             INSERT INTO process_stage_log
                  VALUES (SYSDATE, 'IBS_PDA_BILLS', DURATION, rcount);
         Else
             INSERT INTO process_stage_log
                  VALUES (SYSDATE, 'IBS_PDA_BILLS-D', DURATION, rcount);
         End if;
             CLOSE c2;
             COMMIT;
          EXCEPTION
             WHEN OTHERS
             THEN
                errorsd := SQL%BULK_EXCEPTIONS.COUNT;
                IF errorsd > 0
                THEN
                   FOR j IN 1 .. errorsd
                   LOOP
                      ecode := SQL%BULK_EXCEPTIONS (j).ERROR_CODE;
                      val1 :=
                           vtsch (SQL%BULK_EXCEPTIONS (j).ERROR_INDEX).sch_code;
                      val2 :=
                           vtsch (SQL%BULK_EXCEPTIONS (j).ERROR_INDEX).bpref_no;
                      val3 :=
                         vtsch (SQL%BULK_EXCEPTIONS (j).ERROR_INDEX).bill_month;
                      val4 :=
                         vtsch (SQL%BULK_EXCEPTIONS (j).ERROR_INDEX).service_code;
                  If opr = 'INSERT' Then         
                      INSERT INTO process_error_log
                           VALUES (SYSDATE, ecode, 'IBS_PDA_BILLS', 'sch_code', val1,
                                   'bpref_no', val2, 'bill_month', val3, 'service_code', val4,'INSERT');
              Else
                      INSERT INTO process_error_log
                           VALUES (SYSDATE, ecode, 'IBS_PDA_BILLS', 'sch_code', val1,
                                   'bpref_no', val2, 'bill_month', val3, 'service_code', val4,'DELETE');
              End if;
                   END LOOP;
                END IF;
          END;
       END pda_insert;the program want to do the delet option for all delete is not working. The program executed successful but the operation delete is not happening
    how to solve this issue.
    please help me
    kanish

    No error encountered in my log table
    the new workaround you said, that is instead of for all , already i tried for i in 1.. to like
    instead of forall delete i tried the following way
    Declare
          CURSOR c2 IS
    SELECT *
            FROM ibs_pda_bills_x@testarch1
           WHERE bill_month <= '31-dec-2008'; -- AND bpref_no = :cons;
           opr varchar2(10) := 'DELETE';
          TYPE tsch IS TABLE OF c2%ROWTYPE;
          vtsch      tsch;
          cnt        NUMBER := 0;
          stime      NUMBER;
          etime      NUMBER;
          DURATION   NUMBER;
          rcount     NUMBER;
          errorsd   PLS_INTEGER;
          ecode     NUMBER;
          val1   VARCHAR2 (100);
          val2   VARCHAR2 (100);
          val3   VARCHAR2 (100);
          val4   VARCHAR2 (100);
       BEGIN
          BEGIN
             stime := DBMS_UTILITY.get_time ();
             OPEN c2;
             LOOP
                FETCH c2
                BULK COLLECT INTO vtsch LIMIT 1000;
                IF vtsch.COUNT = 1000
                THEN
                   cnt := cnt + 1;
                END IF;
            If opr = 'INSERT' Then
                    FORALL i IN 1 .. vtsch.COUNT SAVE EXCEPTIONS
                          INSERT INTO dlul.ibs_pda_bills
                        VALUES vtsch (i);
            Else
                   /* fORALL i IN 1 .. vtsch.COUNT SAVE EXCEPTIONS
                     Delete from vw_ibs_pda_bills_x where to_char(bill_month,'dd-mm-rrrr') = to_char(vtsch (i).bill_month,'dd-mm-rrrr');*/
                     for i in 1..vtsch.count loop
                       delete ibs_pda_bills_x@testarch1 where to_char(bill_month,'dd-mm-rrrr') = to_char(vtsch (i).bill_month,'dd-mm-rrrr');
                     end loop; 
            End if;
                EXIT WHEN c2%NOTFOUND;
             END LOOP;
             etime := DBMS_UTILITY.get_time ();
             DURATION := ((etime - stime) / 100) / 60;
             rcount :=
                 (cnt * 1000) + vtsch.COUNT - NVL (SQL%BULK_EXCEPTIONS.COUNT, 0);
         If opr = 'INSERT' Then
             INSERT INTO process_stage_log
                  VALUES (SYSDATE, 'IBS_PDA_BILLS', DURATION, rcount);
         Else
             INSERT INTO process_stage_log
                  VALUES (SYSDATE, 'IBS_PDA_BILLS-D', DURATION, rcount);
         End if;
             CLOSE c2;
             COMMIT;
          EXCEPTION
             WHEN OTHERS
             THEN
                errorsd := SQL%BULK_EXCEPTIONS.COUNT;
                IF errorsd > 0
                THEN
                   FOR j IN 1 .. errorsd
                   LOOP
                      ecode := SQL%BULK_EXCEPTIONS (j).ERROR_CODE;
                      val1 :=
                           vtsch (SQL%BULK_EXCEPTIONS (j).ERROR_INDEX).sch_code;
                      val2 :=
                           vtsch (SQL%BULK_EXCEPTIONS (j).ERROR_INDEX).bpref_no;
                      val3 :=
                         vtsch (SQL%BULK_EXCEPTIONS (j).ERROR_INDEX).bill_month;
                      val4 :=
                         vtsch (SQL%BULK_EXCEPTIONS (j).ERROR_INDEX).service_code;
                  If opr = 'INSERT' Then         
                      INSERT INTO process_error_log
                           VALUES (SYSDATE, ecode, 'IBS_PDA_BILLS', 'sch_code', val1,
                                   'bpref_no', val2, 'bill_month', val3, 'service_code', val4,'INSERT');
              Else
                      INSERT INTO process_error_log
                           VALUES (SYSDATE, ecode, 'IBS_PDA_BILLS', 'sch_code', val1,
                                   'bpref_no', val2, 'bill_month', val3, 'service_code', val4,'DELETE');
              End if;
                   END LOOP;
                END IF;
          END;
       END pda_insert;i am receiving the following error
    ORA-02055: distributed update operation failed; rollback required
    ORA-06531: Reference to uninitialized collection
    ORA-06512: at line 77
    ORA-06531: Reference to uninitialized collection
    kanish

  • I am trying to change the date on an imported home video clip. I entered 9/7/2012 and got 6/9/0339! I checked modify original file, but it is not working. Any ideas?

    I am trying to change the date on an imported home video clip. I entered 9/7/2012 and got 6/9/0339! I checked modify original file, but it is not working. Any ideas?

    Are you using the Adjust Date and Time option or the Batch Change option?  If it's the former try the latter.  If you get the same results  launch iPhoto with the Option key held down and create a new, test library.  Import  the same video file and check to see if the same problem persists.
    OT

  • Multiple delete is not working.

    Hi,
    Multiple delete is not working. Please find my backend bean code. Please let me know the issue in my code.
    Table:
    <af:table value="#{bindings.CmProcessParamValueView13.collectionModel}"
    var="row"
    rows="#{bindings.CmProcessParamValueView13.rangeSize}"
    emptyText="#{bindings.CmProcessParamValueView13.viewable ? 'No data to display.' : 'Access Denied.'}"
    fetchSize="#{bindings.CmProcessParamValueView13.rangeSize}"
    rowBandingInterval="1"
    selectedRowKeys="#{bindings.CmProcessParamValueView13.collectionModel.selectedRow}"
    selectionListener="#{bindings.CmProcessParamValueView13.collectionModel.makeCurrent}"
    rowSelection="multiple"
    binding="#{backingBeanScope.backing_app_RunCalcPage.t1}"
    id="t1" width="720px" inlineStyle="height:140px;" partialTriggers="cb6 cb3"
    filterVisible="true" filterModel="#{bindings.CmProcessParamValueView13.queryDescriptor}" >
    <af:column sortProperty="ParamValue7"
    sortable="true" width="690"
    headerText="Comm Type"
    rowHeader="unstyled"
    id="c2" align="left" filterable="true">
    <af:outputText value="#{row.ParamValue7}"
    id="ot4"/>
    </af:column>
    </af:table>
    Backing Bean Delete Code:
    RowKeySet rowKeySet = (RowKeySet)this.t1.getSelectedRowKeys();
    CollectionModel cm = (CollectionModel)this.t1.getValue();
    System.out.println("RowKeySet is: "+ rowKeySet.getSize());
    for (Object facesTreeRowKey : rowKeySet) {
    cm.setRowKey(facesTreeRowKey);
    JUCtrlHierNodeBinding rowData =
    (JUCtrlHierNodeBinding)cm.getRowData();
    System.out.println("RowData is : "+rowData.getAttribute("ParamValue7"));
    rowData.getRow().remove();
    Thanks.

    Issue is resolved...
    Solution is,
    Remove selectionListener and selectedKey attributes from the table.
    Delete code is:
    DCBindingContainer dcBindings =
    (DCBindingContainer)getBindings();
    DCIteratorBinding dcIterator =
    dcBindings.findIteratorBinding("Iterator...");
    RowSetIterator rs = dcIterator.getRowSetIterator();
    RowKeySet rks = this.t1.getSelectedRowKeys();
    Iterator rksIter = rks.iterator();
    while (rksIter.hasNext()) {
    List l = (List) rksIter.next();
    Key key = (Key)l.get(0);
    Row row = rs.getRow(key);
    if(row != null)
    row.remove();
    }

  • I downloaded the latest firefox 4 and updated my file, firefox 4 will not work with my version of Mac OS X, how do I get my old firefox back?

    I downloaded the latest firefox 4 and updated my file, firefox 4 will not work with my version of Mac OS X, how do I get my old firefox back?

    You can get Firefox 3.6 from http://www.mozilla.com/en-US/firefox/all-older.html

  • HT1750 space.bar.and.delete.key.not.working.on.wireless.keyborad

    space.anddelte
    space.and.delete.keys.not.working.on.wireless.keyboard.help!

    Before replacing the keyboard do 2-3 SMC resets using the instructions in iMac SMC and PRAM reset

  • Is it possible to check automati all bookmarks, and delete the not working bookmarks

    Is it possible to check automatic all bookmarks, and delete the not working bookmarks

    Try this extension:
    *CheckPlaces: https://addons.mozilla.org/firefox/addon/checkplaces/

Maybe you are looking for

  • Add new column to SCASE (BADI/EXIT)

    Hi Gurus, I have requirement to add new column to the ALV grid which is shown when you run (SCASE > case > find dispute cases > execute). I tried using CL_EXITHANDLER, found few BADIs but cannot add any new fields to this ALV from any. Any tips and t

  • Inverntory transfer of an item that exceeds the stock

    Dear Experts,    While doing inventory transfer for a particular item, i am able to enter the quantity greater than the stock and i am able to add it. Shall be more clear.. Consider an item "A" in a warehouse "WH1" with quantity 5. Now when i do an i

  • Problem with pc suite for 8800 please help

    i have my nokia 8800 and want to send up some games, i have a usb bluetooth device and when nokia pc suit goes to pair with phone it says ok on the phone then on the pc it says Can not authorize phone, no com port available, please make a free com po

  • HLS stream cannot renew when adobe media encoder restart

    Hi, I used adobe media server 5.0 in Red Hat 4.1.2 and adobe meida encoder 3.2 to recording HLS stream(get ts file), there's no problem when first running(use jwplayer to view the steam), but when I disconnect adobe media encoder for some time(about

  • Print one email, not entire thread

    My Mail application shows treaded messages of a conversation with the newest message. I'd like to print just one message, not the whole thread, but haven't been able to figure out how to do this.