0%

java | 缓冲流

  • BufferedInputStream
  • BufferedOutputStream
  • BufferedReader
  • BufferedWriter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package 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 会在内存中单独开辟一块缓冲区,然后预先将数据存到缓冲区,用到的时候,从缓冲区读。

请我喝杯咖啡吧~