大文件 - 上传和导入 - Java的 [英] Large Excel File - Upload and Import - Java

查看:436
本文介绍了大文件 - 上传和导入 - Java的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有

我要上传到我的Java程序中导入有超过一百万条记录的大型Excel文件。

I want to upload and import a large excel files having more than one million records in to my Java program.

我可以很容易地在导入使用Apache POI小文件到我的系统,但是当我用大文件启动应用程序将引发和内存不足的错误,

I can easily import small files using Apache POI in to my system , but when i starts with large files application throws and out of memory error,

我搜索谷歌和发现许多线程上的话,我什么都试过,但不能得到这个左右。

任何人可以给我我的具体问题的解决方案,导入时间不是我的问题,现在我也可以用性能问题承担,以及,

can anybody give me solution for my particular problem, import time is not an issue for me, right now also i can bear with performance issue as well,

只是想在我现有的系统导入此数据没有OEM错误。

just want to import this data in to my existing system without oem error.

我有我的系统上非常不错的配置和Java有足够的内存使用,因此硬件不是问题。

感谢

推荐答案

您会想流的数据,这样你就不需要所有的记录存储在内存中的一次。 POI不支持流(见 XSSF和SAX API事件 )。当你阅读资料,船舶它关闭到你需要的地方(数据库或任何地方,你没有指定) - 与流API,你不应该处理之前读取所有数据到内存

You'll want to stream the data so that you don't need to store all the records in memory at once. POI does support streaming (see XSSF and SAX event API). As you read the data, ship it off to wherever you need to (database or wherever, you did not specify) -- with the streaming API you should not read all the data into memory before processing it.

您还可以将数据导出为CSV文件,然后使用普通的的FileInputStream 来读取文件和过程,因为它被读取每个记录。

You could also export the data to a CSV file, and then use a regular FileInputStream to read the file and process each record as it is read.

这篇关于大文件 - 上传和导入 - Java的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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