learning java 处理流的用法

有点重定向使用的味道

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;

public class PrintStreamTest {
    public static void main(String[] args) {
        try {
            var fos = new FileOutputStream("test.txt");
            var ps = new PrintStream(fos);
            {
                ps.println("普通字符串");
                ps.println(new PrintStreamTest());
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}

output:

posted @ 2019-08-05 13:19  嵌入式实操  阅读(161)  评论(0编辑  收藏  举报