zoukankan      html  css  js  c++  java
  • Java基础IO类之打印流

    package IODemo;
    
    import java.io.*;
    /*
    打印流 : 很方便的进行输出
    字节打印流
        增强输出功能
    
    字符打印流
     */
    public class PrintStreamDemo {
    
    
    
        private  static  void charPrint(){
            File file = new File("d:\test\t.txt");
            try {
                Writer w = new FileWriter(file,true);
                BufferedWriter br = new BufferedWriter(w);
                PrintWriter ps = new PrintWriter(br);
                ps.println("嗨~");
                ps.close();
    
            } catch (IOException e) {
                e.printStackTrace();
            }
    
        }
    
        private static void bytePrint(){
            File file = new File("d:\test\t.txt");
            try {
                OutputStream out = new FileOutputStream(file,true);
                BufferedOutputStream bos = new BufferedOutputStream(out);
                PrintStream ps  =new PrintStream(bos);
                ps.println("好好学习天天向上");
                ps.close();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
    
        }
    
    
        public static void main(String[] args) {
    
      //  bytePrint();
            charPrint();
        }
    }

    如上代码

  • 相关阅读:
    11月20日
    11月19日
    11月26日
    11月25日
    生活有感(一)
    c# word 删除指定内容
    mysql insert语句
    c# 删除word文档中某一页
    mysql 相同表结构拷贝数据
    调试再次出错
  • 原文地址:https://www.cnblogs.com/lpss-75074038/p/11979936.html
Copyright © 2011-2022 走看看