源码
package com.io;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
public class BufferedInputStreamTest {
public static void main(String[] args) throws Exception {
String path = "D:" + File.separator + "helloworld.txt";
FileInputStreamReadFile(path);
}
public static void FileInputStreamReadFile(String path) {
try (InputStream bis = new BufferedInputStream(new FileInputStream(new File(path)))) {
byte[] buf = new byte[1024];
int len = 0;
while ((len=bis.read(buf)) != -1) {
System.out.println(new String(buf,0,len));
}
} catch (Exception e) {
}
}
}