@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();
}
}