I have a class Test and a folder with a textfile abc.txt in it. How can I write in this file? I have tried this, but it doesn't work (no Exception):
public static void main(String[] args) throws IOException {
try {
PrintWriter pWriter = new PrintWriter(new BufferedWriter(new FileWriter("abc.txt")));
pWriter.println("Hello World!");
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
When I write new FileWriter("/abc.txt")
instead of new FileWriter("abc.txt")
I get the following
Exception: java.io.FileNotFoundException: \abc.txt (Zugriff verweigert).