try
{
FileWriter fw = new FileWriter("demo.txt");
fw.write("JavaIO练习");
} catch (IOException e) {
e.printStackTrace();
}
}
这样写的话,无法输出字符串;
之后按照这样写就可以了
try
(FileWriter fw = new FileWriter("demo.txt"))
{
fw.write("JavaIO练习");
} catch (IOException e) {
e.printStackTrace();
}
}
哪位大神告诉我这是为什么? |
|