This is my code to delete a folder , this below code wont delete the Downloads directory under home folder.
import java.io.IOException;
public class tester1{
public static void main(String[] args) throws IOException {
System.out.println("here going to delete stuff..!!");
Runtime.getRuntime().exec("rm -rf ~/Downloads/2");
//deleteFile();
System.out.println("Deleted ..!!"); }
}
However if I give the complete home path, this works :
import java.io.IOException;
public class tester1{
public static void main(String[] args) throws IOException {
System.out.println("here going to delete stuff..!!");
Runtime.getRuntime().exec("rm -rf /home/rah/Downloads/2");
//deleteFile();
System.out.println("Deleted ..!!");
}
}
Can anybody tell me what am I doing wrong.?
You're using shell syntax without a shell. Change the command to this: