import java.io.FileWriter;
import java.io.IOException;
public class TestWriter {
public static void main(String[] args) {
try {
FileWriter fw = new FileWriter("D:\\test.txt");
fw.write("Hello!");
} catch (IOException e) {
e.printStackTrace();
}
fw.flush();
fw.close();
}
}
再Eclipse中,fw.flush(); fw.close(); 这两句会报错,但写在try里面就不会报错,如何解决? |