我想读取文件的一些字节,从“偏移”,它的长度是“大小”。所以我使用FIleInputStream和此代码:错误:indexoutofbound。当读取文件的一些字节
byte[] data = new byte[size];
FileInputStream fis=new FileInputStream(inputFile);
System.out.println("offset:"+offset+","+"size:"+size);
fis.read(data, offset, size);
所以我有偏移量和大小的真实值,但我接收器错误:indexoutofbound。我不明白。任何人都可以展示我跌倒的方式,以及是否有其他正确的方式来做到这一点?
不是'fis.read(data,offset,size);'应该是'fis.read(data,offset,size-1);' –