JAVA的IO问题

yqh2009 2007-03-08 06:56:35
import java.io.*;

class test12 {
public static void main(String args[]){
File f1=new File("yqh.txt");
File f2=new File("2009.txt");
FileOutputStream fout=null;
FileWriter fw=null;
PrintStream ps=null;
PrintWriter pw=null;

try{
fout=new FileOutputStream(f1);
fw=new FileWriter(f2);
ps=new PrintStream(fout);
pw=new PrintWriter(fw);
ps.write("FGHFGHF".getBytes());
pw.write("asasdsdfdsffsdf");
// pw.flush();
}catch(Exception e){}

}

}

为什么ps明明没有刷新的啊,2009那个文件就有数据,而yqh那个文件里没有数据。
...全文
243 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
yqh2009 2007-03-08
  • 打赏
  • 举报
回复
我知道这样就会有数据,但是我不明白ps没有刷新,f1里面就有数据呢??
chenxb1980 2007-03-08
  • 打赏
  • 举报
回复
ps.flush();ps.close();
pw.flush();pw.close();

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧