How to check if excel file is blank?
<p>I have excel file (<code>*.xls</code> or <code>*.xlxs</code>) which can have records or no records. First I store the file in some temp location, then copy the contents of the file and then tried to read the file. This scenario works fine if the excel sheet contains records but if the sheet has no record and the file is empty. This scenario does not work. I am using apache-poi to read the excel file contents.</p>

<pre><code>public static boolean isRowEmpty(Row row) {
    for (int c = row.getFirstCellNum(); c &lt; row.getLastCellNum(); c++) {
        Cell cell = row.getCell(c);
        if (cell != null &amp;&amp; cell.getCellType() != Cell.CELL_TYPE_BLANK) {
            return false;
        }
    }
    return true;
}
</code></pre>

<p>I get <code>IOException : unable to read entire header 0 bytes read expected 512 bytes</code>. Can somebody suggest me a way to get rid of this exception and check the excel file is empty?</p>