据我所知,Java迫使您以字节为单位读取文件,而不是阻止读取。如果要序列化Java对象,那就大不一样了。
所示的其他示例将DataInputStream类与File一起使用,但您也可以使用快捷方式:RandomAccessFile类:
RandomAccessFile in = new RandomAccessFile("filename", "r");int version = in.readInt();byte type = in.readByte();int beginOfData = in.readInt();byte[] tempId;in.read(tempId, 0, 16);String id = new String(tempId);请注意,您可以将响应对象变成一个类,如果那样的话会更容易。



