仅从Pagesize的文件中读取记录
我是初学者,我有一个包含可变大小记录的文件;每行有两个字段 即一个是 7-15 位数字键,然后是空格,这是一个字符串,每个记录的大小也是可变的。
我正在尝试仅将页面大小的字节读入缓冲区,然后处理它们。
问题是,如果我使用Java.RanomAccessFile 并使用seek 方法来到达特定行,那么我使用ReadFully 方法将这1024 个字节读入我的缓冲区。我已经编写了将 byte 转换为 int 和将 byte 转换为 string 的函数 - 但问题是我不知道有多少字节形成 7-15 数字以及有多少字节形成我的字符串。
I am a beginner and I have a file having variable sized records; there are two fields per row
i.e. one is 7-15 digits key and then followed by space there is a string which is also variable sized for each record.
I am trying to read bytes only of page size into my buffer and then process them.
The problem is that if i use Java.RanomAccessFile and use seek method to reach a particular line , then i use ReadFully method to read those 1024 bytes into my buffer. I have written the functions to convert byte into int and byte into string -but the problem is that I dont know how many bytes form that 7-15 digit and how many bytes form my string.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当你说一行时,你的意思是每行之间都有一个行分隔符吗?如果是这种情况,您可以使用 BufferedReader 的 readline() 方法之类的方法。这给你一个 1 行的字符串,没有行分隔符。
When you say a row, do you mean each row has a line separator in between? If that is the case, you can use something like BufferedReader's readline() method. That gives you a string which is 1 line without the line separator.