我有一个类Test和一个带有文本文件abc.txt的文件夹。我怎么写这个文件?我试过这个,但它没有用(没有例外):
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();
}
}
当我写new FileWriter("/abc.txt")
代替new FileWriter("abc.txt")
时,我得到以下内容
异常:java.io.FileNotFoundException:\ abc.txt(Zugriff verweigert)。