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();
    }


    }

  • 相关阅读:
    M1卡的工作原理【转】
    磁卡ID卡IC卡的区别【转】
    磁卡结构【转】
    M1卡破解(自从学校升级系统之后,还准备在研究下)【转】
    RunJS演示代码
    Linux中inet_aton的问题(IP转整数)
    使用Hive UDF和GeoIP库为Hive加入IP识别功能
    hive下UDF函数的使用
    linux下smb
    使用Spring MVC表单标(转)
  • 原文地址:https://www.cnblogs.com/hph1728390/p/10611474.html
Copyright © 2011-2022 走看看