java | 缓冲流 发表于 2022-12-25 分类于 java , 基础 , IO 阅读次数: Valine: BufferedInputStream BufferedOutputStream BufferedReader BufferedWriter 1234567891011121314151617package com.redisc;import lombok.extern.slf4j.Slf4j;import java.io.*;@Slf4j(topic = "c.Test")public class Run { public static void main(String[] args) throws IOException { InputStream is = new FileInputStream(""); // 低级字节包入高级字节 BufferedInputStream bis = new BufferedInputStream(is); int len = bis.read(); }} 其原理是,java 会在内存中单独开辟一块缓冲区,然后预先将数据存到缓冲区,用到的时候,从缓冲区读。 请我喝杯咖啡吧~ 打赏 微信支付 支付宝