RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
java_io_打印流,PrintStream和PrintWriter

*PrintStream和PrintWriter,效果相似

创新互联是专业的南部网站建设公司,南部接单;提供做网站、成都网站设计,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行南部网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

  • PrintStream ps=new PrintStream(字节流,true/false),为真则自动刷新内容,默认为假
  • System.out默认为PrintStream 打印流
  • 写入文件(通过.println):
  • PrintStream ps=new printStream(new BufferedStream(FileOutputStream("vv.txt")),true)
  • ps.println("ad")
  • 重定向输出端(输出到文件):System.setOut(ps); ps.println("aa");
  • 重定向回控制台:System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out)),true));

PrintStream:

        //打印流System.out
        PrintStream os =System.out;
        os.println("haha");

    //写入文件
    os= new PrintStream(new BufferedOutputStream(new FileOutputStream("vv.txt")),true);
    os.println("add");
    os.println(false);
    os.flush();
    os.close()

    //重定向输出端(输出到文件)
    System.setOut(os);
    System.out.println("change");

    //重定向回控制台
    System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out)),true));
    //标准的输入输出端

PrintWriter:

    PrintWriter pw=new PrintWriter(new BufferedOutputStream(new FileOutputStream("vv.txt")),true);
    pw.println("ff");
    pw.println(true);
    pw.close();

网页名称:java_io_打印流,PrintStream和PrintWriter
转载注明:http://scyingshan.cn/article/gpjiji.html