File f = new File("src/abc.txt");
// project structure/Modules/ Use modules compile output path选中即显示相对路径
InputStream io = new FileInputStream(f);
byte[] flush= new byte[4];
int len = -1;
//io.read()末尾返回-1,其他返回相应int
while((len = io.read(flush))!=-1){
//len不可少 否则会在byte[]后附加
System.out.print(new String(flush,0,len)+" ");
}
io.close();
字节流字节数组
最新推荐文章于 2024-06-11 15:49:24 发布