我,谢谢您的关注.
我想使用Java将大量数据,实际上是大量数据(600万行)导出到.csv文件.该应用程序是使用toplink(ojdbc14)的JPA摆动应用程序.
我尝试使用:
但是BufferedWriter
RandomAccessFile的
FileChannel
等等,但是尽管我将最大堆大小设置为800m(-Xmx800m),但是内存消耗仍然很高,导致Java堆内存不足异常.
我的源代码的最新版本:
...(more lines of code)
FileChannel channel = getRandomAccessFile(tempFile).getChannel();
Object[][] data = pag.getRawData(); //Database data in a multidimentional array
for (int j = 0; j < data.length; j++) {
write(data[j], channel); //write data[j] (an array) into the channel
freeStringLine(data[j]); //data[j] is an array, this method sets all positions =null
data[j] = null;//sets reference in null
}
channel.force(false); //force writing in file system (HD)
channel.close(); //Close the channel
pag = null;
...(more lines