天天看点

PrintStream

/*

  * 打印流

  * 字节打印流

  * PrintStream

  * 构造函数可以接收的参数类型

  * 1.file对象。File

  * 2.字符串路径。String

  * 3.字节输出流,Writer

  * 

  * 字符打印流

  * PrintWriter

  * 

  */

 public class EncodeStream {

       public static void main(String[] args) throws IOException {

BufferedReader bufr=new BufferedReader(new InputStreamReader(System.in));

//PrintWriter out=new PrintWriter(System.out);//写到控制台

//PrintWriter out=new PrintWriter("G:\\demo.txt");//写到文本里

PrintWriter out=new PrintWriter(new FileWriter("G:\\sds.txt"),true);//自动刷新

String line=null;

while((line=bufr.readLine())!=null){

if("over".equals(line)){

break;

}

out.println(line.toUpperCase());

//out.flush();

}


out.close();

bufr.close();

}     

 }      

继续阅读