FileInputStream fileInputStream = new FileInputStream("test_dir/test_file.txt"); byte[] buffer = new byte[1024]; fileInputStream.read(buffer); for (byte b : buffer) { System.out.println(b); } fileInputStream.close();
FileInputStream fileInputStream = new FileInputStream("test_dir/test_file.txt"); int x; while((x=fileInputStream.read())!= -1) System.out.println(x); fileInputStream.close();
上面2段代码输出的数字为何不同?(忽略byte数组多余的零)
onemoo
慕沐9307871
相关分类