zoukankan      html  css  js  c++  java
  • 字符缓冲流

    字符缓冲流

    1.缓冲流:不具备读写数据的能力,可以提高读取数据的效率,扩展功能,内部维护字符数组                                                                    

                                                                              

     2.BufferedReader:缓冲输入字符流                                              

    1. 特殊功能:readLine()     读取一行数据                              

       1.创建通道并指定路径                                                    

        FIleReader reader = new FileReader(“D:\a.txt”);         

       2.创建缓冲流                                                            

        BufferedReader buffer = new BufferedReader(reader);     

       3.循环读取一行                                                          

        String string = null;                                                  

        while((string = buffer.readLine()) != null){                 

            System.out.println(string);                                        

    }                                                                      

       4.关闭流                                                                

        buffer.close();                                                    

                                                                               

    3.BufferedWrite:缓冲输出字符流                                            

    1.内部提供一个8192长度的字符数组作为缓冲区                           

    2.作用:                                                                  

          A)提高写入的效率                                                    

          B)提高FileWrite的功能                                              

     3. 特殊功能:newline();  数据换行显示                                  

      1.创建通道并指定路径                                                     

        FileWrite write = new FIleWrite(“D:\a.txt”);          

      2.建立缓冲流                                                             

        BuferedWrite buffer = new BufferedWrite(write);           

      3.数据换行显示                                                           

        buffer.newLine();                                       

      4.开始写入数据    //   也是系统换行                                  

        Buffer.write(“这是要写入的数据”);                                 

      5.关闭资源 (会自动调用flush())                                         

        bufferedWrite.close();

  • 相关阅读:
    选择排序遇到的引用和传值问题记录
    The web application [ROOT] appears to have started a thread named [spring.cloud.inetutils] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
    IDEA中实用的插件
    Column 'status' specified twice
    Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'dataType' in 'field list'
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where id = 2' at line 8
    Missing URI template variable 'id' for method parameter of type long
    值传递和引用传递的区别
    SpringBoot项目与数据库交互,访问http://localhost:8888/admin/userInfo时,报org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
    SpringBoot项目启动时报错:org.apache.catalina.LifecycleException: Protocol handler start failed
  • 原文地址:https://www.cnblogs.com/z-jun/p/6179991.html
Copyright © 2011-2022 走看看