import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;public class Test4 { public static void main(String[] args) throws IOException { // 获得字节输入流对象 FileInputStream fileInputStream =
import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;public class Test4 { public static void main(String[] args) throws IOException { // 获得字节输入流对象 FileInputStream fileInputStream = new FileInputStream("a.txt"); // 获取数据 byte[] bytes = new byte[4]; int len = fileInputStream.read(bytes); // 遍历 while (len != -1) { // 遍历字节数组 获取字节成员 for (int i = 0; i < len; i++) { byte b = bytes[i]; System.out.println(b); } // 重新获取一下数据 更新len的值 len = fileInputStream.read(bytes); } // 关闭资源 fileInputStream.close(); System.out.println("game over"); }}