装饰者模式输入
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")));
//创建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")));
相关文章推荐
- java学习笔记(1)-----关于interface
- C++学习——构造函数初始化列表
- 内存管理文章(1)
- 股神的十个境界 你达到了第几级?
- eclipse scm url下拉为空
- 《大道至简》第五章读后感
- 随机数数组 框图输出
- Objective-C之Category的使用
- HTTP长连接和短连接原理浅析
- 【Usaco2015 Feb】【BZOJ3943】SuperBull
- Go语言项目(kingshard)性能优化实例剖析
- 处理同时进行多个网络请求的方法
- Python入门课程总结-导图版
- Android 动画实践
- 树,二叉树
- 指针
- 单片机printf使用
- Acronis Disk Director Suite v10 扩容系统盘
- Lesson 5 Convenience typedefs
- LeetCode——Search a 2D Matrix II