1

I have a requirement to transform xml data to a Excel file. I have the code that works fine when I write to a file, however, when I try to write to an Output Stream, the code is not working.

All I am trying to do was to create an excel file using Apache POI classes, and write to an Output Stream and pass it back to Oracle B2B, which would create an excel file in the SFTP server.

The below code works just fine, (Writing to a file, using FileOutPutStream)

        FileOutputStream output1 =
            new FileOutputStream(new File("C:\\Oracle\\Middleware\\home_11gR1\\user_projects\\domains\\mysoa_domain\\dsp\\PO_1234.xls"));
        workbook.write(output1); 

The below code does not work,

   workbook.write((ByteArrayOutputStream)output);

I am not sure what would be the problem here. Any ideas and suggestions are greatly appreciated.

1 Answers1

0

Try closing the stream. Maybe if you leave it open the information written will not get flushed.

Also consider using buffered stream for your IO

gerrytan
  • 40,313
  • 9
  • 84
  • 99
  • Thanks, I have closed the stream,It appears to be that the "output" which is a list, when tried to convert to an OutputStream is what is causing the problem, however, I am not sure how to write the workbook to an outputstream. – user1902612 Dec 14 '12 at 04:47