如何编写许多logging来批量生成.xlsx文件?

我正在尝试批量写入大量的logging。

在这里我总共有25条logging,我正在写20条logging,然后是5条logging。 但FileOutputStream(filename,true)不附加到以前的书面logging。

 package orginal; public class ReadWriteExcelFile { static XSSFWorkbook wb = null; static XSSFRow row = null; /** * @param args */ public static void main(String[] args) { try { writeXLSFile(); } catch (IOException e) { e.printStackTrace(); } } @SuppressWarnings("unchecked") public static void writeXLSFile() throws IOException { String excelFileName = "C:\\Users\\RK\\Music\\500.xlsx"; String sheetName = "Sheet1"; wb = new XSSFWorkbook(); XSSFSheet sheet = wb.createSheet(sheetName); FileOutputStream fileOut = new FileOutputStream(excelFileName, true); ArrayList arrList = new ArrayList(); for (int i = 0; i < 25; i++) { arrList.add("Row ::" + i); } ArrayList aTemp1 = new ArrayList(); int r = 0; // Writing first batch // iterating r number of rows for (r = 0; r < 20; r++) { createData(sheet, r); } writeRec(fileOut); for (int l = r; l < arrList.size(); l++) { aTemp1.add(arrList.get(l)); } // Writing second batch for remaining records extra than the bacth size. for (int k = r; k < arrList.size(); k++) { createData(sheet, k); } fileOut = new FileOutputStream(excelFileName, true); writeRec(fileOut); System.out.println("done"); } private static void createData(XSSFSheet sheet, int r) throws IOException { row = sheet.createRow(r); // iterating c number of columns for (int c = 0; c < 10; c++) { XSSFCell cell = row.createCell(c); cell.setCellValue("Cell " + r + " " + c); } } private static void writeRec(FileOutputStream fileOut) throws IOException { wb.write(fileOut); fileOut.flush(); fileOut.close(); } 

}