We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

java.io.IOException: End of file reached - Word Document

Hi

I'm getting an exception while instantiating Document object. The below line of code causing the exception :

Document doc1 = new Document(inputstream, null, LoadFormat.DOC, null);

The exception message is:

java.io.IOException: End of file reached.
at com.aspose.words.b.c(Unknown Source)
at com.aspose.words.b.d(Unknown Source)
at com.aspose.words.b.f(Unknown Source)
at com.aspose.words.b.g(Unknown Source)
at com.aspose.words.c.(Unknown Source)
at com.aspose.words.jr.a(Unknown Source)
at com.aspose.words.jr.(Unknown Source)
at com.aspose.words.kx.a(Unknown Source)
at com.aspose.words.kx.(Unknown Source)
at com.aspose.words.eb.(Unknown Source)
at com.aspose.words.Document.a(Unknown Source)
at com.aspose.words.Document.a(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.templatesdisplay.TemplatesDisplay.applyTemplates(TemplatesDisplay.java:386)

Best Regards,
Bala

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Could you please attach your document here for testing? I will check the problem on my side and provide you more information.

Best regards,

Hi

Please find the attached document which I'm using for testing.

Best Regards,
Bala

Hi Bala,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I cannot reproduce the problem on my side. I used the following code for testing:

Document doc = new Document("C:\\Temp\\Sample+BAA.doc");

doc.save("C:\\Temp\\out.doc");

Also I tried using stream:

FileInputStream docStream = new FileInputStream("C:\\Temp\\Sample+BAA.doc");

Document doc = new Document(docStream);

doc.save("C:\\Temp\\out.doc");

Best regards,

Hi Andrey,

Thanks for your reply.

Yes, I agree with you but when I'm using SbmFileInputStream I'm getting the above exception. I believe that the below line of code causing the exception :

InputStream stream = new SbmFileInputStream (new SbmFile(fileUrl));

Document doc1 = new Document(stream, null, LoadFormat.DOC, null);

Best Regards,
Bala

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I tried also with SmbFileInputStream and all works file on my side. Here is sample code I used for testing:

NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("SERV", "mylogin", "mypassword");

String url = "smb://SERV/Temp/Test.doc";

SmbFile smbFile = new SmbFile(url, auth);

InputStream smbStream = new SmbFileInputStream(smbFile);

Document doc = new Document(smbStream);

doc.save("C:\\Temp\\out.doc");

Best regards.

Could you please provide me the ASPOSE version which you are executed the above sample program?
Because we are getting the above exception with ASPOSE 2.0 but not with ASPOSE 3.0.
The code is working fine with ASPOSE 3.0.
From the above analysis it has been concluded that the issue is due to different version used. Please confirme the same from your end also.


Thanks for quick response.

Best Regards,
Bala

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I used the latest version of Aspose.Words for testing. You can download the latest version from here:

http://www.aspose.com/community/files/72/java-components/aspose.words-for-java/category1378.aspx

There is no sense to test with older versions because issues are always fixed in newer versions.

Best regards.