java delete file from folder -
i trying delete file: code , can't see wrong
system.out.println("users//"+"user"+i.getid()); file f=new file("users//"+"user"+i.getid()); system.out.println("can read: "+f.canread()); system.out.println("can write: "+f.canwrite()); system.out.println("can exec: "+f.canexecute()); system.out.println("exists: "+f.exists()); system.out.println(f.delete());
yes, have right read,write,exec , file exists. don't have exceptions
i have tried code , works:
public static void main(string[] args) { try { file file = new file("c:\\users\\akhil\\logfile11052015.log"); if (file.delete()) { system.out.println("success: " + file.getname() + " deleted!"); } else { system.out.println("failed: delete operation failed."); } } catch (exception e) { e.printstacktrace(); } }
may can check if providing correct path in case , file exists there.
output: success: logfile11052015.log deleted!
Comments
Post a Comment