System hang while using Apache-POI java library for reading an excel file
<p>I used Apache-POI java library for reading excel files, it worked well. I read about 100 cells of every excel file, then I close the excel file.</p>

<p>The strange is when the excel file has large data, it will read the data successfully and then into another function system would crash. </p>

<p>I would appreciated any idea to solve this problem.</p>

<p>I am using this code for reading the excel file:</p>

<pre><code>public void ExcelReader(String path,int range1, int range2)
{
    try
    {
      // Read from original Excel file.

      FileInputStream file = new FileInputStream(path);

      Workbook workbook = WorkbookFactory.create(file);

      // Get the first sheet.
      Sheet sheet = workbook.getSheetAt(0);

      int allocated = range2 - range1 +1;

      BarcodeList = new int [allocated];
      int count = 0;

      for(int i=range1-1; i&lt;allocated; i++)
      {
          Row row = sheet.getRow(i);
          Cell cell = row.getCell(0);

          double x = Double.parseDouble(cell.toString());
          int y = (int) x;

          BarcodeList[count] = y;


          count++;    
      }

      file.close();


    }
    catch(NullPointerException e)
    {
      System.out.println(e);
    }
    catch(FileNotFoundException e)
    {

      System.out.println(e);
    }
    catch(IOException e)
    {
      System.out.println(e);
    }
    catch(InvalidFormatException e)
    {
      System.out.println(e);
    }


}
</code></pre>
