• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

delete()

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
For some reason, I ran into peculiar situation sometimes delete() works, and other times it doesnt, especially when I put the code snippet as part of a bigger application. I just wonder if anyone have similar experience.
Example:
....
String fileName=(String)listbox.getSelectedValue();
System.out.println("file to be deleted= "+fileName);//printed filename correctly
File f = new File("c:\\temp", fileName);
System.out.println(f.delete());//printed 'false' even if the file is indeed in the c:\temp directory as specified, and it's not deleted
or in other simple case...
import java.io.*;
public class del {
public static void main(String args[]) {
File path = new File("c:\\temp");
File f=new File(path,"somefilename");
System.out.println(f.delete());//printed 'false' even if the file with "somefilename" exists in c:\temp
}}
 
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic