• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
}}
 
Your mind is under my control .... your will is now mine .... read this tiny ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic