简体   繁体   English

Java中逐行随机访问文件查找操作

[英]Random Access file seek operation line by line in java

I have large text file in a sorted form. 我有一个排序形式的大文本文件。 I want to search records and insert new record in this file. 我想搜索记录并在此文件中插入新记录。 For searching binarySearch looks better choice but to implement binary search I need a seek operation which will works on line number(Random Access File seek operation works on offset or byte length in java) Please guide me what will the better alternative to perform search operation in sorted file using java. 为了搜索binarySearch看起来更好的选择,但是要实现二进制搜索,我需要一个可以在行号上运行的搜索操作(随机访问文件的seek操作可以在java中的偏移量或字节长度上运行)请指导我在以下情况下执行搜索操作的更好选择使用Java对文件进行排序。

您始终可以使用line-> byte indexing实施二进制搜索,这样您就知道要跳转到什么偏移量了...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM