zoukankan      html  css  js  c++  java
  • BufferedInputStream

     1 package file;
     2 
     3 import java.io.BufferedInputStream;
     4 import java.io.File;
     5 import java.io.FileInputStream;
     6 import java.io.IOException;
     7 
     8 public class Demo3 {
     9     public static void main(String[] args) throws IOException {
    10         readTest();
    11     }
    12     
    13     //BufferedInputStream维护的是一个字节数组,8192
    14     //凡是缓冲流,都不具备读写文件的能力
    15     public static void readTest() throws IOException {
    16         File file = new File("F:\2.txt");
    17         FileInputStream fileInputStream = new FileInputStream(file);
    18         //建立缓冲输入字节流
    19         //因为BufferedInputStream不具备读写文件的能力,要借助FileInputStream
    20         BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
    21         
    22         //读取文件数据
    23         int content = 0;
    24         while((content = bufferedInputStream.read()) != -1) {
    25             System.out.println((char)content);
    26         }
    27         
    28         //关闭资源
    29         bufferedInputStream.close();    //实际上关闭的FileInputStream的close
    30     }
    31 }
  • 相关阅读:
    开启CTF大门
    关于windows下scapy出现log_runtime问题
    Python关于Threading暂停恢复解决办法
    angr入门之CLE
    Linux信号量
    IDApython 命令
    Array 数组对象
    随机数 random()
    四舍五入round()
    向下取整floor()
  • 原文地址:https://www.cnblogs.com/linst/p/5660576.html
Copyright © 2011-2022 走看看