我已经按照代码将一些字符串写入文件中。
String fileToWrite = System.getProperty("user.dir") + "\\testdata\\towrite.txt";
File file = new File(fileToWrite);
String toWrite = "This is to write to a file. Goodbye!";
FileWriter output = new FileWriter(fileToWrite);
BufferedWriter writer = new BufferedWriter(output);
writer.write(toWrite);
但是当我打开文件时,我可以看到它是空的。意味着没有任何东西写入它。你能说出我在这里做错了吗?