zoukankan      html  css  js  c++  java
  • 打印流 在文件中写内容

    import java.io.BufferedReader;


    import java.io.File;


    import java.io.FileInputStream;


    import java.io.FileOutputStream;


    import java.io.IOException;


    import java.io.InputStreamReader;


    import java.io.ObjectInputStream;


    import java.io.ObjectOutputStream;


    import java.io.PrintWriter;



    public class Object1 {
        

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

                    fun11();

                 fun12();

        }

        public static void fun11() throws IOException {


    //              创建读去写入的文本


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


    //        在文件下打印写入的内容


              PrintWriter out =new PrintWriter (new File("D:\11.txt"));


    //            字符长度为空


                String line = null;


    //            读取的长度不能为空


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


    //                如果输入over就退出输入


                 if ("over".equals(line))


                      break;


    //                打印输入的内容


                    out.println(line.toUpperCase());


    //                刷新IO流


                    out.flush();
                
            }


    //        关闭流


            out.close();
            buf.close();


        }

              public static void fun12() throws IOException {


    //                  创建读去写入的文本、


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


    //                  在控制台输入内容


                    PrintWriter out =new PrintWriter (System.out);


    //                  字符长度为空


                      String line = null;


    //                读取的长度不能为空


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


    //            如果输入over就退出输入


                  if ("over".equals(line))


                      break;


    //                打印输入的内容


                    out.println(line.toUpperCase());


    //                刷新IO流


                    //out.flush();


                
            }


    //        关闭流


            out.close();


            buf.close();
    }


    }

  • 相关阅读:
    【工具篇】利用DBExportDoc V1.0 For MySQL自动生成数据库表结构文档(转
    PHP Client for Mysql Binlog
    MySQL的binlog日志恢复(转)
    Linux 普通进程 后台进程 守护进程(转)
    实战:MySQL Sending data导致查询很慢的问题详细分析(转)
    mysql索引无效且sending data耗时巨大原因分析
    阿里云-DRDS(转)
    MySQL查看SQL语句执行效率(转)
    nginx php-fpm 输出php错误日志(转)
    Golang指针基本介绍及使用案例
  • 原文地址:https://www.cnblogs.com/hph1728390/p/10611474.html
Copyright © 2011-2022 走看看