缓冲一个大文件;BufferedInputStream 限制为 2GB;数组限制为 2^31 字节 [英] Buffer a large file; BufferedInputStream limited to 2gb; Arrays limited to 2^31 bytes

查看:30
本文介绍了缓冲一个大文件;BufferedInputStream 限制为 2GB;数组限制为 2^31 字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按顺序处理一个大文件,我想将其中的一大块保存在内存中,在 64 位系统上有 16GB 内存可用.

一个快速而肮脏的方法是这样做,只需将输入流包装到一个缓冲输入流中,不幸的是,这只给了我一个 2gb 的缓冲区.我想在内存中保留更多,我有什么选择?

解决方案

您是否考虑过 java.nio 中的 MappedByteBuffer?它在我的头上,但也许这就是你要找的.

I am sequentially processing a large file and I'd like to keep a large chunk of it in memory, 16gb ram available on a 64 bit system.

A quick and dirty way is to do this, is simply wrap the input stream into a buffered input stream, unfortunately, this only gives me a 2gb buffer. I'd like to have more of it in memory, what alternatives do I have?

解决方案

Have you considered the MappedByteBuffer in java.nio? It's over my head but maybe it is what you are looking for.

这篇关于缓冲一个大文件;BufferedInputStream 限制为 2GB;数组限制为 2^31 字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆