您的位置:首页 > 其它

装饰者模式输入

2015-11-02 20:51 141 查看
try{
//创建FileWrier对象,用来写入字符串
String fileName = "F:\\n.txt";
//创建文件输出对象流 用文件对象作为参数 则对该文件进行输出操作
FileOutputStream fos = new FileOutputStream(new File(fileName));
//采用装饰模式实例化PrintStream流
PrintStream ps = new PrintStream(fos);

ps.printf("总成绩: %d \n平均分: %f", total ,average);

ps.close();
}
catch(FileNotFoundException e){
e.printStackTrace();
}

//-------------------------------------

PrintStream ps = new PrintStream(new FileOutputStream(new File("F:/n.txt")));
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: