我需要在xlsx文件中写一个超过65000行的结果集.所以我想尝试使用Apache POI 3.7.但我收到OutOfMemoryError的错误:Java堆空间.除了增加似乎无法解决问题的JVM内存之外,我该如何解决这个问题.请帮忙.
简单示例代码:
public static void main(String[] args) throws IOException {
Workbook wb = new XSSFWorkbook();
CreationHelper createHelper = wb.getCreationHelper();
Sheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
for (int i=0;i<65000;i++){
Row row = sheet.createRow((int) i);
// Create a cell and put a value in it.
Cell cell = row.createCell(0);
cell.setCellValue(1);
// Or do it on one line.
row.createCell(1).setCellValue(1.2);
row.createCell(2).setCellValue(
createHelper.createRichTextString("This is a string"));
row.createCell(3).setCellValue(true);
}
// Write …Run Code Online (Sandbox Code Playgroud) 我有一个旧的perl脚本,它一直在工作,但突然有些东西被打破,而不是删除文件.
-rw-r--r-- 1 nobody uworld 6 Dec 03 11:15 shot32.file
Run Code Online (Sandbox Code Playgroud)
删除上述文件的命令位于perl脚本中
`rm $shotfile`;
Run Code Online (Sandbox Code Playgroud)
我检查过$ shotfile是shot32.file,它位于正确的位置.所以文件位置和文件名不是问题.
关于权限,perl脚本也在nobody用户下运行,因此可能是其他原因导致无效.
感谢您的帮助.