Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error : Bad file descriptor

RAMJANEJul 23 2012 — edited Jul 24 2012
Hi All,

I am getting Bad file descriptor error message while trying to run the below code :
try {

  HSSFWorkbook wb = new HSSFWorkbook();
  HSSFSheet sheet = wb.createSheet("Excel Sheet");
  HSSFRow rowhead = sheet.createRow((short) 0);
  rowhead.createCell((short) 0).setCellValue("Roll No");
  rowhead.createCell((short) 1).setCellValue("Name");
  rowhead.createCell((short) 2).setCellValue("Class");
  rowhead.createCell((short) 3).setCellValue("Marks");
  rowhead.createCell((short) 4).setCellValue("Grade");

  int index = 1;
 
  while (index<=110){

        HSSFRow row = sheet.createRow((short) index);
        row.createCell((short) 0).setCellValue(index);
        row.createCell((short) 1).setCellValue("Java");
        row.createCell((short) 2).setCellValue("Write to Excel");
        row.createCell((short) 3).setCellValue(index+15);
        row.createCell((short) 4).setCellValue("NA");
          index++;
  }
 	  FileOutputStream fileOut = new FileOutputStream("\\\\remotepc1111\\C$\\test\\TestExcel.xls");
	wb.write(fileOut);
	fileOut.close();
 }
catch (Exception e) {
System.out.println(e.getMessage());

}
I read some where on the internet that this could be because of fileOut.close(). I tried after commenting that, but result was same.

Could some one point me what mistake I am making.

Thanks a lot.

AR
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 21 2012
Added on Jul 23 2012
7 comments
685 views