@Test
public void test() {
String filePath = "C:\Users\xxxxx8\Desktop\temp.txt";
byte[] buff = new byte[1024]; // 一次取出的字节大小
int i = 0;
try (FileInputStream fis = new FileInputStream(filePath)) {
// i的目的在于防止最后一次读取的字节小于b长度,否则会自动被填充0
if ((i = fis.read(buff)) != -1) {
System.out.println(new String(buff, 0, i));
}
} catch (IOException e) {
e.printStackTrace();
}
}