缓冲流写不了文件,求指点!
程序代码:
//缓冲流对文件进行读写 import *; public class Example12_7{ public static void main(String args[]){ File file=new File("sb3.txt"); String content[]={"大爷好","二爷我不好","三爷最近我心里烦","四爷我最近手头紧"}; String content_2[]=new String[content.length]; try{ FileWriter outOne=new FileWriter(file); BufferedWriter outTwo=new BufferedWriter(outOne); for(String s:content){ System.out.println(s); outTwo.write(s); //conetent内容没有被写入文件?哪里出问题了? outTwo.newLine(); } outOne.close(); outTwo.close(); FileReader inOne=new FileReader(file); BufferedReader inTwo=new BufferedReader(inOne); for(int i=0;i<content.length;i++){ content_2[i]=inTwo.readLine(); System.out.println(content_2[i]); } inOne.close(); inOne.close(); } catch(IOException e){}; } }
[ 本帖最后由 a4811 于 2013-1-26 09:28 编辑 ]