博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
打印流
阅读量:4495 次
发布时间:2019-06-08

本文共 733 字,大约阅读时间需要 2 分钟。

打印流

/** * 使用PrintStream进行输出 * */import java.io.*;class hello {    public static void main(String[] args) throws IOException { PrintStream print = new PrintStream(new FileOutputStream(new File("d:" + File.separator + "hello.txt"))); print.println(true); print.println("Rollen"); print.close(); } }

【运行结果】:

trueRollen

当然也可以格式化输出

/** * 使用PrintStream进行输出 * 并进行格式化 * */import java.io.*;class hello {    public static void main(String[] args) throws IOException { PrintStream print = new PrintStream(new FileOutputStream(new File("d:" + File.separator + "hello.txt"))); String name="Rollen"; int age=20; print.printf("姓名:%s. 年龄:%d.",name,age); print.close(); } }

【运行结果】:

姓名:Rollen. 年龄:20.

转载于:https://www.cnblogs.com/yuyu666/p/9733904.html

你可能感兴趣的文章
iOS 设置控件大小根据文本的大小
查看>>
MapReduce Design Patterns(7、输入输出模式)(十四)
查看>>
JS函数式编程【译】3.2 开发和生产环境
查看>>
火柴棍等式
查看>>
EasyUI中DataGrid构建复合表头
查看>>
[转]How to compile GDB for iOS!
查看>>
redis windows安装
查看>>
python有序字典OrderedDict()
查看>>
sql 检索字符串
查看>>
常用正则表达式
查看>>
HDU 4280 最大流Dinic算法优化
查看>>
八大排序算法
查看>>
why dropout work?
查看>>
小白成长记-----python实现注册的小程序
查看>>
Codeforces Round #151 (Div. 2)总结
查看>>
cin问题 分类: c++ 2014-08-02 2...
查看>>
PHP 中文字符串相关
查看>>
开始搭建 myBatis.net + Spring.net + asp.net mvc 3 + easyUI 开发平台
查看>>
vue-cli的项目中关于axios的全局配置
查看>>
动软.Net代码生成器
查看>>