guwenren
package string.itcastio;

import java.io.*;

/*
 * 打印流
 * 该流提供了打印方法,可以将各种数据类型的数据都原样打印
 * 字节打印流
 * PrintStream
 * 构造函数可以接收的参数类型
 * 1,file对象。File
 * 2,字符串路径。String
 * 3,字节输出流 。OutputStream
 * 字符串打印
 * PrintWriter
 * 构造函数可以接收的参数类型
 * 1,file对象。File
 * 2,字符串路径:String
 * 3,字节输出流: OutputStream
 * 4,字符输出流:Writer
 * 
 */
public class PrintStreamDemo {
    public static void main(String[] args) throws IOException {
        method();
    }

    public static void method() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new FileWriter("a.txt"), true);
        String line = null;
        while ((line = br.readLine()) != null) {
            if ("over".equals(line)) {
                break;
            }
            out.println(line);
        }
        br.close();
        out.close();

    }
}

 

分类:

技术点:

相关文章:

  • 2021-08-15
  • 2021-10-15
  • 2021-08-15
  • 2021-11-03
  • 2021-10-15
  • 2019-01-24
  • 2021-11-07
  • 2018-06-26
猜你喜欢
  • 2021-11-07
  • 2021-08-15
  • 2021-10-16
  • 2021-09-24
  • 2021-08-15
  • 2021-08-15
  • 2021-08-15
相关资源
相似解决方案