This code creates a .txt in the folder directory (it works) but when comes the time to delete the whole directory or the .txt file using delete()
method, nothing happens.
The delete()
method works only when I replace the .txt file with an ordinary folder
import java.io.*;
public class Filemkdir {
public static void main(String[] args) throws Exception {
File f = new File("C:/Temp/Java/secret.txt");
FileWriter fSecret = new FileWriter(f);
f.mkdir();
f.delete();
}
}