Hello,
I am trying to create a file and then delete it. This code does create file a.txt, but won't delete it pls help me. And I would also like to know, if a file is deleted through a program, does it go to recycle bin??
RegardsCode:import java.io.FileWriter;
import java.io.File;
import java.io.Writer;
import java.io.FileNotFoundException;
import java.io.IOException;
public class fileop {
public static void main(String[] args) {
Writer writer = null;
try {
String word = "hello";
File f1 = new File("a.txt");
writer = new BufferedWriter(new FileWriter(f1));
writer.write(word);
f1.delete();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Maya

