You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Ju...@VerizonWireless.com on 2003/08/08 20:44:56 UTC
Unable to read entire block
Hello,
I am trying to use POI to read the an Excel spreadsheet on a UNIX system.
The following code works fine when run on Windows but when run on UNIX I
receive an error.
As a test I read the same file on both system. To get the file to the UNIX
system I ftp it in binary format from the Windows system.
The error I receive is :
"Unable to read entire block; 88 bytes read; expected 512 bytes
at org.apache.poi.poifs.storage.RawDataBlock.<init>(RawDataBlock.java:98)
at
org.apache.poi.poifs.storage.RawDataBlockList.<ini>(RawDataBlockList.java:88
)
at
org.apache.poi.poifs.filesstem.POIFSFileSystem.<init>(POIFSFileSystem.java:1
23)
...
Code follows:
public Collection readFile(String iFileName) throws IOException
{
// create a new file input stream with the input file specified by param
iFileName
FileInputStream fin = new FileInputStream(iFileName);
// create a new org.apache.poi.poifs.filesystem.Filesystem
POIFSFileSystem poifs = new POIFSFileSystem(fin);
// get the Workbook (excel part) stream in a InputStream
InputStream din = poifs.createDocumentInputStream("Workbook");
// construct out HSSFRequest object
HSSFRequest req = new HSSFRequest();
// lazy listen for ALL records with the listener shown above
req.addListenerForAllRecords(this);
// create our event factory
HSSFEventFactory factory = new HSSFEventFactory();
// process events based on the document input stream
factory.processEvents(req, din);
// once all the events are processed close file input stream
fin.close();
// close document input stream
din.close();
return returnCol;
}
I also tried using the BufferedInputStream as suggested in the mail archives
but t does not find the file.
POIFSFileSystem poifs = null;
InputStream excel = getClass().getResourceAsStream(iFileName);
if (excel != null) {
try {
poifs = new POIFSFileSystem(new BufferedInputStream(excel));
} catch (IOException e) {
e.printStackTrace();
throw e;
}
}
else {
throw new IOException("Exception: could not read
inputfile:"+iFileName);
}
Any help would be MUCH APPRECIATED!!!!!
Thanks,
Julio
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
Re: Unable to read entire block
Posted by "Andrew C. Oliver" <ac...@apache.org>.
What version is this? I think you're hitting the concurrency bug. This is
fixed in 2.0pre3. We would do a 1.52 but we're so close to release time
that it seems silly to do so.
I've patched this for 2 client thus far by grabbing the 1_5 branch and
replacing LittleEndian roughly with the one from the 2_0 branch.
Theoretically this could also be a really slow filesystem (NFS)...
-andy
On 8/8/03 2:44 PM, "Julio.Font@VerizonWireless.com"
<Ju...@VerizonWireless.com> wrote:
> Hello,
> I am trying to use POI to read the an Excel spreadsheet on a UNIX system.
> The following code works fine when run on Windows but when run on UNIX I
> receive an error.
> As a test I read the same file on both system. To get the file to the UNIX
> system I ftp it in binary format from the Windows system.
> The error I receive is :
> "Unable to read entire block; 88 bytes read; expected 512 bytes
> at org.apache.poi.poifs.storage.RawDataBlock.<init>(RawDataBlock.java:98)
> at
> org.apache.poi.poifs.storage.RawDataBlockList.<ini>(RawDataBlockList.java:88
> )
> at
> org.apache.poi.poifs.filesstem.POIFSFileSystem.<init>(POIFSFileSystem.java:1
> 23)
> ...
>
> Code follows:
>
> public Collection readFile(String iFileName) throws IOException
> {
> // create a new file input stream with the input file specified by param
> iFileName
> FileInputStream fin = new FileInputStream(iFileName);
>
> // create a new org.apache.poi.poifs.filesystem.Filesystem
> POIFSFileSystem poifs = new POIFSFileSystem(fin);
>
> // get the Workbook (excel part) stream in a InputStream
> InputStream din = poifs.createDocumentInputStream("Workbook");
>
> // construct out HSSFRequest object
> HSSFRequest req = new HSSFRequest();
>
> // lazy listen for ALL records with the listener shown above
> req.addListenerForAllRecords(this);
>
> // create our event factory
> HSSFEventFactory factory = new HSSFEventFactory();
>
> // process events based on the document input stream
> factory.processEvents(req, din);
>
> // once all the events are processed close file input stream
> fin.close();
>
> // close document input stream
> din.close();
>
> return returnCol;
> }
>
> I also tried using the BufferedInputStream as suggested in the mail archives
> but t does not find the file.
> POIFSFileSystem poifs = null;
> InputStream excel = getClass().getResourceAsStream(iFileName);
> if (excel != null) {
> try {
> poifs = new POIFSFileSystem(new BufferedInputStream(excel));
> } catch (IOException e) {
> e.printStackTrace();
> throw e;
> }
> }
> else {
> throw new IOException("Exception: could not read
> inputfile:"+iFileName);
> }
>
> Any help would be MUCH APPRECIATED!!!!!
>
> Thanks,
> Julio
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List: http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
>
--
Andrew C. Oliver
http://www.superlinksoftware.com/poi.jsp
Custom enhancements and Commercial Implementation for Jakarta POI
http://jakarta.apache.org/poi
For Java and Excel, Got POI?
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/