Writer的子类,既可以接收字符流,也可以接收字节流,还可以接收文件名或者文件对象,非常方便

同时,还可以设置自动刷新以及保持原有格式写入各种文本类型的print方法

PrintWriter的小例子:打印字符录入的大写

//读取键盘录入,打印大写
throws IOException
   3: {
   4:     BufferedReader bufr =
new InputStreamReader(System.in));
   6:  
new PrintWriter(System.out,true);
   8:  
   9:     String line = null;
  10:  
while( (line = bufr.readLine()) != null)
  12:     {
.equals(line))
break;
//只需一条语句,便可打印一行数据,非常方便
  16:         out.println(line.toUpperCase());
  17:     }
  18:     
  19:     out.close();
  20:     bufr.close();
  21: }

相关文章:

  • 2021-12-02
  • 2022-02-20
  • 2021-12-04
  • 2022-03-04
  • 2021-06-17
  • 2021-08-29
  • 2021-11-22
  • 2021-10-15
猜你喜欢
  • 2021-10-23
  • 2021-08-03
  • 2021-05-29
  • 2022-12-23
  • 2021-12-04
  • 2021-07-30
  • 2022-01-04
相关资源
相似解决方案