使用缓存字节数组读取java字节流时,第一次读取是,读满缓存字节数组大小,才进行下次读取,还是随机读一个小于数组大小的值,再进行下次读取???
读取本地文件时,首次读取读满整个字节数组,在进行下次读取。
package com.lyf.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.junit.Test;
public class ReadFile {
@Test
public void readTxt() {
InputStream is = null;
String path = this.getClass().getClassLoader().getResource("abc.txt")
.getPath();
System.out.println(path);
String content = "";
String loopContentString ="";
try {
is = new FileInputStream(path);
byte buff[] = new byte[16];
int len = is.read(buff);
content = new String(buff, 0, len);