My code was correct where I was reading in the file. I missed code above that point where I created a new file with 0 bytes. It didn't have any data or a header, so I got the error.
-----Original Message----- From: Danny Mui [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 12:01 PM To: DRINKARD, JAMES E (SBCSI) Subject: Re: Problem reading in a file I got that error once before when the file I was reading was 0 bytes. Make sure the file does have something in it. danny DRINKARD, JAMES E (SBCSI) wrote: >Hello All, >I'm trying to read in an excel file and I keep getting an error due to it >not being able to read the header? I made the file using POI and then >populated it with data. That part works fine. Then I try to read that file >in order to change it using the following code: > >try > { > POIFSFileSystem fs = new POIFSFileSystem(new >FileInputStream(fileName)); > HSSFWorkbook wrkBk = new HSSFWorkbook(fs); > >fileName is a string variable with the filename and path: ie >"c:\temp\test.xls". > >The error is: >java.io.IOException: Unable to read entire header; -1 bytes read; expected >512 bytes >java.io.IOException: Unable to read entire header; -1 bytes read; expected >512 bytes > at >org.apache.poi.poifs.storage.HeaderBlockReader.<init>(HeaderBlockReader.jav a >:114) > at >org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java : >120) > at >com.sbc.ecom.iris.batch.reports.totals.Totals.main(Totals.java:303) > >I know from other documentation I read that the header gets read first, so >if it can't find it or interpret it, I assume this is the error one would >get. > >Any ideas as to what I'm doing wrong? > >Thanks, >James > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
