日期:2014-05-17  浏览次数:20696 次

JAVA 用BufferedWriter 怎么能将数字输入到txt文件中
这是我的代码,麻烦大家看一下:
int k = 2;
try{
File filePath = new File("target.txt");
  BufferedWriter bw = new BufferedWriter(new FileWriter(filePath));
  bw.write(k);
  }
  catch( Exception e ) {  
  System.out.println( "Exception:"+e );
}
bw有write(int)的函数,但是就是写不进文件当中,文件显示0KB,问大家有没有解决的办法

------解决方案--------------------
bw.flush();
bw.close();
然后再看看?