我在jave中有一个项目,我在其中创建了一个二进制文件,并在其中写入了学生数据。 现在我想跳过用户插入的字符串字节,但我不知道怎么做而不读它。 我怎么知道我需要倾斜的字节长度是多少? 插入的数据是'int,string,int ...'等等。 我使用RandomAccessFile,kode是:
if(ranf.readInt()==id)
{
found=true;
ranf.readUTF();
System.out.println("please enter new grade:");
new_grade=s.nextInt();
ranf.write(new_grade);
}
else{
ranf.readUTF();
ranf.readInt();
location=ranf.getFilePointer();
}
- 第一个int值是id-im首先读取学生的id然后如果它与输入不匹配我想跳过下一个 - 不读取下一个'String,int'