且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

大文件 - 上传和导入 - Java的

更新时间:2023-01-15 15:06:10

您会想流的数据,这样你就不需要所有的记录存储在内存中的一次。 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.