Results 1 to 5 of 5
  1. #1
    shekhariet is offline Member
    Join Date
    Apr 2013
    Posts
    3
    Rep Power
    0

    Default java program which delete file and recover it

    Help help.....

    I tried a java program which simply delete file(.txt) from perticuler location like ("D:\MyTestFolder") and then recover it at same place.

    Please help me.......

    Rgds,
    Shekhar

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    929
    Rep Power
    2

    Default Re: java program which delete file and recover it

    Java cannot recover a deleted file. You need specialized tools for that, which can be found through Google.

  3. #3
    shekhariet is offline Member
    Join Date
    Apr 2013
    Posts
    3
    Rep Power
    0

    Default Re: java program which delete file and recover it

    Thanks for your valuable response.....

    My teacher gave me assignment.I have to complete it in any way.

    Is there any other way to recover file like...
    1) any batch (.bat file) commands
    or
    2) c/c++/php program which can recover file........

    Thanks

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default Re: java program which delete file and recover it

    Depends how you want to class "delete".
    Could you "delete" it by moving it to some other location (a bit like Windows does with the Trash folder)?
    Then yoru recover simply copies it back.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    shekhariet is offline Member
    Join Date
    Apr 2013
    Posts
    3
    Rep Power
    0

    Default Re: java program which delete file and recover it

    This is my code to delete '.txt' files from specific folder(D:/javatest).I don't know how to recover these deleted filles.Please add some code,if possible, to achive
    the same.I know,it is not possible in java.So would you please help me(may be in any other language.)


    import java.*;
    import java.io.File;
    class CountFiles{
    public static void main(String args[]){
    String dirPath="D:/javatest";
    File f = new File(dirPath);
    File[] files = f.listFiles();
    int s=files.length;
    System.out.println("Number of files in folder "+s);
    for(int i=0;i <s; i++)
    {
    if (files[i].isFile())
    {
    String FilesName = files[i].getName();
    if (FilesName.endsWith(".txt") || FilesName.endsWith(".TXT")) //display only list of txt files
    {
    System.out.println(FilesName);
    boolean success = files[i].delete();
    if (!success)
    throw new IllegalArgumentException("Delete: deletion failed");
    else System.out.println("file deleted");
    }
    System.out.println("file deleted out side.....");
    }
    }
    }
    }

Similar Threads

  1. how to delete a line from a file in java
    By Hemanth Kumar in forum Advanced Java
    Replies: 28
    Last Post: 04-18-2012, 03:21 AM
  2. Trigger cmd to delete a file in java program
    By hari.kr in forum Advanced Java
    Replies: 4
    Last Post: 04-28-2010, 07:37 PM
  3. How to Recover Deleted Files from Eclipse ?
    By vinod827 in forum Eclipse
    Replies: 1
    Last Post: 08-02-2009, 12:07 PM
  4. delete a line from a text file in Java
    By ddatta8 in forum New To Java
    Replies: 2
    Last Post: 01-24-2009, 05:08 AM
  5. Replies: 1
    Last Post: 11-10-2008, 09:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •