Results 1 to 3 of 3
  1. #1
    vaibhavspawar is offline Member
    Join Date
    Jun 2010
    Posts
    17
    Rep Power
    0

    Default Deleting '.zip' file...

    Hello Friends...
    I've written some code to delete '.zip' file. But it isn't working.

    File file = new File(some_file_name.zip); <-- I've given absolute path.
    System.out.println("FILE name to delete : "+ file.getName());
    boolean isDeleted = file.delete();
    System.out.println("isDeleted : "+isDeleted);

    M getting correct filename whatever i've given, but m getting
    the flag value as 'false'.

    Please Help....!!!
    Thanks.... :)

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by vaibhavspawar View Post
    Hello Friends...
    I've written some code to delete '.zip' file. But it isn't working.

    File file = new File(some_file_name.zip); <-- I've given absolute path.
    System.out.println("FILE name to delete : "+ file.getName());
    boolean isDeleted = file.delete();
    System.out.println("isDeleted : "+isDeleted);

    M getting correct filename whatever i've given, but m getting
    the flag value as 'false'.
    Can you manage to delete that file manually? If not probably some other process is keeping that file open ...

    kind regards,

    Jos

  3. #3
    vaibhavspawar is offline Member
    Join Date
    Jun 2010
    Posts
    17
    Rep Power
    0

    Default About deleting '.zip' file...

    Thanks JosAH,
    I was unable to delete the file using the code stated earlier. So I tried
    it in some lengthy way . Bt it worked.
    After getting filename, I found I got it's Directory name using
    file.getParent(). Then I listed the files within it using listFiles().
    & using counter I deleted files one by one. It's lengthy bt it works.
    Thanks again. :)

Similar Threads

  1. Deleting multiple lines of text from a file
    By barman in forum New To Java
    Replies: 4
    Last Post: 06-29-2010, 09:12 AM
  2. File Not Deleting
    By Moncleared in forum New To Java
    Replies: 7
    Last Post: 02-21-2010, 08:28 PM
  3. [SOLVED] deleting a line from a text file
    By mokonji in forum New To Java
    Replies: 0
    Last Post: 03-10-2009, 01:35 PM
  4. Help deleting a file
    By 3speed in forum New To Java
    Replies: 4
    Last Post: 11-01-2008, 05:27 AM
  5. Deleting a File that is opened
    By ravian in forum Advanced Java
    Replies: 6
    Last Post: 01-30-2008, 02:05 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
  •