day20/PrintStreamDemo.java

来源:互联网 发布:网络远程教育学校 编辑:程序博客网 时间:2024/06/01 13:06
/*打印流:该流提供了打印方法,可以将各种数据类型的数据都原样打印。字节打印流:PrintStream构造函数可以接收的参数类型:1.file对象。File2.字符串路径。String3.字节输出流。OutputStream字符打印流:PrintWriter构造函数可以接收的参数类型:1.file对象。File2.字符串路径。String3.字节输出流。OutputStream4.字符输出流。 Writer*/import java.io.*;class PrintStreamDemo {public static void main(String[] args) throws IOException{BufferedReader bufr = new BufferedReader(new InputStreamReader(System.in));PrintWriter out = new PrintWriter(System.out,true);//构造函数带true,自动刷新String line=null;while((line=bufr.readLine())!=null){out.println(line);}bufr.close();out.close();}}

0 0
原创粉丝点击