小内存读取大文件实战
内存只有1M但是读取1G的文件并对出现字符的频率排序top5
- 获取文件
- 定义每次读取文件的大小
- 通过BufferedReader获取根据每次读取1m文件
- 每次读取一行,并放到hashMap中
- 遍历map并排序
public class topCharactorCounter {
public static void main(String[] args) {
File file = new File("E:\\1.txt");
int memoryLimit=1024*1024;
int bufferSize=1024;
Map<Character,Integer> chmap

最低0.47元/天 解锁文章
1471

被折叠的 条评论
为什么被折叠?



