zoukankan      html  css  js  c++  java
  • 字符缓冲流 读取文件



    import java.io.*;


    //      字节传输的缓冲流


    public class Buff1 {



            public static void main(String[] args) {


                  BufferedInputStream bos=null;


                  try {


    //                  读取D盘的内容


                     bos=new BufferedInputStream(new FileInputStream("d:\IO\ac.txt"));


    //                   速度为1kb


                    byte [] b=new byte[1024];


                
                      int len=0;


    //                read不能你等与-1


                    while ((len=bos.read(b))!=-1){


                    
                        System.out.println(new String(b,0,len));
                    
                }


            } catch (Exception e) {


              
                e.printStackTrace();


            }finally{


                  if(bos!=null){


                    try {


                          bos.close();


                    } catch (IOException e) {


                        
                        e.printStackTrace();
                    }
                }
            }

        }

    }

  • 相关阅读:
    原型设计
    简单APP——ToDoList的二次开发(日期规范化+构建搜索栏)
    Java基本语言篇
    C++中各种常用转换汇总学习
    语言篇swift
    洛谷P2384 最短路,积化加
    洛谷P4568 分层图最短路
    【洛谷P1962】矩阵快速幂求Fibonacii数列
    vue-cli教程
    单页应用原理
  • 原文地址:https://www.cnblogs.com/hph1728390/p/10601162.html
Copyright © 2011-2022 走看看