打印流的知识点整理

	/**
	 * @throws IOException 
	 * 构造函数接收的三种类型值:
	 * 1、字符串路径
	 * 2、File对象
	 * 3、字节输出流
	 * print方法可以自动刷新,并且能保持数据的表现形式
	 */
	public static void main(String[] args) throws IOException {
		PrintStream ps = new PrintStream("print1.txt");
		ps.write(97);//只写整数中的低八位,4个字节变成1个字节
		ps.print(97);//将97变成字符串打印,一个字节变成两个字节
		ps.close();
	}


 

public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out,true);
		//PrintWriter pw2=new PrintWriter(new FileWriter("Demo.txt"),true);
		//将目的文件关联到输出流中,就可以在创建对象时,传入boolean型的true,使得打印时可以自动刷新
		String line=null;
		while((line=br.readLine())!=null){
			if("over".equals(line))
				break;
			pw.println(line.toUpperCase());
		}
	}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值