public class Test{
public static void main(String args[]){
try{
File f = new File("stat.txt");
FileWriter fw = new FileWriter(f);
fw.write("dasfd"); }catch(IOException e){System.out.println(e.getMessage());}
}
}程序是执行了,但是stat.txt里什么也没有,怎么回事呢?
public static void main(String args[]){
try{
File f = new File("stat.txt");
FileWriter fw = new FileWriter(f);
fw.write("dasfd"); }catch(IOException e){System.out.println(e.getMessage());}
}
}程序是执行了,但是stat.txt里什么也没有,怎么回事呢?
class Test{
public static void main(String args[]){
try{
File f = new File("stat.txt");
FileWriter fw = new FileWriter(f);
fw.write("dasfd");
fw.close(); //加是这句
}catch(IOException e){System.out.println(e.getMessage());}
}
}
见鬼了,原来是没CLOSE,真粗心,谢谢各位