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!

uploading PDF file results to corrupted file

807580Sep 16 2010 — edited Sep 21 2010
Hi,

I have the following java code that saves a pdf file into a local location

tempFile = new File(this.getRecFilename());
ByteArrayOutputStream baos=new ByteArrayOutputStream();
FileInputStream in=new FileInputStream(tempFile);

int read=-1;

while((read=in.read())!=-1) {
baos.write(read);
}
this.setRecData(baos.toByteArray());

It is working perfectly except for this one particular PDF file, once it saves the file to the local directory, the file becomes corrupted. I'm not sure why this happens because I tried out other PDF files that are larger than this one and some other that has editable fields in it but they don't get corrupted.

Please advise.

Thanks in advance!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 19 2010
Added on Sep 16 2010
21 comments
1,524 views