Results 1 to 2 of 2
  1. #1
    Alpha is offline Member
    Join Date
    May 2007
    Posts
    4
    Rep Power
    0

    Default How to delete a file

    Is it possible to delete a file with Java?

  2. #2
    FaRuK is offline Member
    Join Date
    May 2007
    Posts
    7
    Rep Power
    0

    Default

    You can use following code segment to delete a file:

    Java Code:
        boolean success = (new File("filename")).delete();
        if (!success) {
            // Deletion failed
        }
    For similar information, you can check documentation for the File class:

    File (Java 2 Platform SE v1.4.2)

Similar Threads

  1. [SOLVED] Delete Current line from file
    By Azndaddy in forum New To Java
    Replies: 2
    Last Post: 04-06-2012, 08:00 AM
  2. Listbox Add/Delete
    By Rageagainst20 in forum New To Java
    Replies: 2
    Last Post: 04-16-2008, 04:49 PM
  3. Replies: 0
    Last Post: 04-05-2008, 10:13 AM
  4. Store retrieve and delete
    By on7june in forum New To Java
    Replies: 1
    Last Post: 03-08-2008, 05:57 PM
  5. problem when I try to delete a file
    By tommy in forum Advanced Java
    Replies: 2
    Last Post: 07-31-2007, 02:44 PM

Posting Permissions

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