Q:

how to get last row of excel in POI and append blank row? 

how to get last row of excel in POI and append blank row and write the next record after the blank row
Below is my code snippet
public class ResultSetToExcel {
            private HSSFWorkbook workbook;
            private HSSFSheet sheet;
            private HSSFFont boldFont;
            private HSSFDataFormat format;
            private ResultSet resultSet;
            private FormatType[] formatTypes;

            public ResultSetToExcel(ResultSet resultSet, FormatType[] formatTypes, String sheetName) {
                workbook = new HSSFWorkbook();
                this.resultSet = resultSet;
                sheet = workbook.createSheet(sheetName);
                boldFont = workbook.createFont();
                boldFont.setBoldweight(HSSFFont. BOLDWEIGHT_BOLD);
                format = workbook.createDataFormat();
                this.formatTypes = formatTypes;
            }

            public ResultSetToExcel(ResultSet resultSet, String sheetName) {
                this(resultSet, null, sheetName);
            }

            private FormatType getFormatType(Class _class) {
                if (_class == Integer.class || _class == Long.class) {
                    return FormatType. INTEGER;
                } else if (_class == Float.class || _class == Double.class) {
                    return FormatType. FLOAT;
                } else if (_class == Timestamp.class || _class == java.sql.Date.class) {
                    return FormatType. DATE;
                } else {
                    return FormatType. TEXT;
                }
            }

            public void generate(OutputStream outputStream) throws Exception {
                try {
                    ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
                    if (formatTypes ! = null && formatTypes.length ! = resultSetMetaData.getColumnCount()) {
                        throw new IllegalStateException("Number of types is not identical to number of resultset columns. " 
                                + "Number of types: " + formatTypes.length + ".  Number of columns: "
                                + resultSetMetaData.getColumnCount());
                    }
                    int currentRow = 0;
                    HSSFRow row = sheet.createRow(currentRow);
                    int numCols = resultSetMetaData.getColumnCount();
                    boolean isAutoDecideFormatTypes;
                    if (isAutoDecideFormatTypes = (formatTypes == null)) {
                        formatTypes = new FormatType[numCols];
                    }
                    for (int i = 0; i < numCols; i++) {
                        String title = resultSetMetaData.getColumnName(i + 1);
                        writeCell(row, i, title, FormatType. TEXT, boldFont);
                        if (isAutoDecideFormatTypes) {
                            Class _class = Class.forName(resultSetMetaData.getColumnClassName(i + 1));
                            formatTypes[i] = getFormatType(_class);
                        }
                    }

                    currentRow++; // Write report rows
                    while (resultSet.next()) {
                        row = sheet.createRow(currentRow++);
                        for (int i = 0; i < numCols; i++) {
                            Object value = resultSet.getObject(i + 1);
                            writeCell(row, i, value, formatTypes[i]);
                        }
                    }
                    // Autosize columns
                    for (int i = 0; i < numCols; i++) {
                        sheet.autoSizeColumn((short) i);
                    }
                    workbook.write(outputStream);
                } finally {
                    outputStream.close();
                }
            }

            public void generate(File file) throws Exception {
                generate(new FileOutputStream(file));
            }

            private void writeCell(HSSFRow row, int col, Object value, FormatType formatType) throws NestableException {
                writeCell(row, col, value, formatType, null, null);
            }

            private void writeCell(HSSFRow row, int col, Object value, FormatType formatType, HSSFFont font)
                    throws NestableException {
                writeCell(row, col, value, formatType, null, font);
            }

            private void writeCell(HSSFRow row, int col, Object value, FormatType formatType, Short bgColor, HSSFFont font)
                    throws NestableException {
                HSSFCell cell = HSSFCellUtil.createCell(row, col, null);
                if (value == null) {
                    return;
                }
                if (font ! = null) {
                    HSSFCellStyle style = workbook.createCellStyle();
                    style.setFont(font);
                    cell.setCellStyle(style);
                }
                switch (formatType) {
                case TEXT:
                    cell.setCellValue(value.toString());
                    break;
                case INTEGER:
                    cell.setCellValue(((Number) value).intValue());
                    HSSFCellUtil.setCellStyleProperty(cell, workbook, HSSFCellUtil. DATA_FORMAT, HSSFDataFormat
                            .getBuiltinFormat(("#,##0")));
                    break;
                case FLOAT:
                    cell.setCellValue(((Number) value).doubleValue());
                    HSSFCellUtil.setCellStyleProperty(cell, workbook, HSSFCellUtil. DATA_FORMAT, HSSFDataFormat
                            .getBuiltinFormat(("#,##0.00")));

                    break;
                case DATE:
                    cell.setCellValue((Timestamp) value);
                    HSSFCellUtil.setCellStyleProperty(cell, workbook, HSSFCellUtil. DATA_FORMAT, HSSFDataFormat
                            .getBuiltinFormat(("m/d/yy")));
                    break;
                case MONEY:
                    cell.setCellValue(((Number) value).intValue());
                    HSSFCellUtil.setCellStyleProperty(cell, workbook, HSSFCellUtil. DATA_FORMAT, format
                            .getFormat("($#,##0.00);($#,##0.00)"));
                    break;
                case PERCENTAGE:
                    cell.setCellValue(((Number) value).doubleValue());
                    HSSFCellUtil.setCellStyleProperty(cell, workbook, HSSFCellUtil. DATA_FORMAT, HSSFDataFormat
                            .getBuiltinFormat("0.00%"));
                }
                if (bgColor ! = null) {
                    HSSFCellUtil.setCellStyleProperty(cell, workbook, HSSFCellUtil. FILL_FOREGROUND_COLOR, bgColor);
                    HSSFCellUtil
                            .setCellStyleProperty(cell, workbook, HSSFCellUtil. FILL_PATTERN, HSSFCellStyle. SOLID_FOREGROUND);
                }
            }

            public enum FormatType {
                TEXT, INTEGER, FLOAT, DATE, MONEY, PERCENTAGE
            }
        }

And class implementing the above code
  ResultSetToExcel resultSetToExcel = new ResultSetToExcel(iResultSet, csv_file_name); 
             int fileCount = 1; 
             while (true) { 
             boolean done = resultSetToExcel.generate(new File(csv_file_path+ csv_file_name)); 
             if (done) break; 
             csv_file_name = csv_file_name + "_" + fileCount + ".xls"; 
             fileCount++; 
             } 

Edit:
I used below snippet
InputStream myxls = new FileInputStream("test.xls");
 Workbook book = new HSSFWorkbook(myxls); 
Sheet sheet = book.getSheetAt(0); 
System.out.println(sheet.getLastRowNum()); 

But I get this error 
java.io. IOException: Unable to read entire header; 0 bytes read; expected 512 bytes

A:

The key bit is the exception is the number 0:

java.io. IOException: Unable to read entire header; 0 bytes read; expected 512 bytes

POI went to read the 512 byte header that should be at the start of the file, but found 0 bytes in the file - your file is empty. 
Make sure you're passing in the correct filename to load. ( You mention struts in your tag, you might not be in the directory you expected to be when running...)
Also, I'd suggest a slight improvement to your code.  You have a file, and you're using the common interfaces, so you should change how you load the workbook.  Instead of your current:
InputStream myxls = new FileInputStream("test.xls");
Workbook book = new HSSFWorkbook(myxls); 

You'd be much better off with
Workbook book = WorkbookFactory.create(new File("test.xls"));

Loading directly from a file, rather than going via an InputStream, will give better performance and a lower memory footprint.  By using the WorkbookFactory, your code can work for both XLS and XLSX files.