IO流输出换行问题

File file=new File("address");
FileInputStream in=new FileInputStream("file");
InputStreamReader read=new InputStreamReader("in","utf-8");
BufferedReader buf=new BufferedReader(read);
String str="";
StringBuffer strbuf=new StringBuffer();
while((str=buf.readLine())!=null){
  strbuf.append(str);
  //换行
  strbuf.append(System.getProperty("line.separator"));            
}
buf.close();
//输出
File file2=new File("输出地址");
//如果地址存在不执行,不存在创建地址文件
flie2.creatNewFile();
PrintWriter out=new PrintWriter(file2);
out.write(strbuf.toString());
out.flush();
out.close();

 

posted on 2017-04-16 22:26  十字街~  阅读(405)  评论(0编辑  收藏  举报