4

java | 缓冲流

 1 year ago
source link: https://benpaodewoniu.github.io/2022/12/25/java144/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

java | 缓冲流

2022-12-25java基础IO

1

  • BufferedInputStream
  • BufferedOutputStream
  • BufferedReader
  • BufferedWriter
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 会在内存中单独开辟一块缓冲区,然后预先将数据存到缓冲区,用到的时候,从缓冲区读。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK