简体   繁体   English

使用RandomAccessFile和多线程时,如何拆分大字符文件?

[英]When using RandomAccessFile and Multi Thread, How do I split big char file?

I have to read a big char file.Then I have found RandomAccessFile which meets my need. 我必须读取一个大的char文件,然后找到满足我需要的RandomAccessFile I have a try, then faced with a question that how to get the point that every thread starts with. 我尝试一下,然后遇到一个问题,即如何弄清楚每个线程的起点。

The RandomAccessFile API read file by byte, but the file is charset and I need to process every line.so How do I spilt it by line ? RandomAccessFile API按字节读取文件,但是该文件是字符集,我需要处理每一行。因此,如何按行将其溢出?

thanks help. 谢谢帮助。

Can not do this with NIO. NIO无法做到这一点。

I have to read a big char file. 我必须阅读一个大的char文件。

So you should be using FileReader , probably wrapped in a BufferedReader . 因此,您应该使用FileReader ,它可能包装在BufferedReader

However reading a file with multiple threads won't buy you anything. 但是,读取具有多个线程的文件不会为您带来任何好处。 The disk isn't multi-threaded. 磁盘不是多线程的。

And you can't read lines in parallel. 而且您不能并行读取行。 It doesn't even make sense, 甚至都没有道理

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

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