Search code examples
javafilejakarta-eedatahandler

DataHandler, trying to write its content into a file


I am having a DataHandler problem.

I am trying to collect their contents in a file. This is created with the size of the buffer allocated damaged but without content, so I do not get to write anything on it.

This is the code i'm using: Important, the "ciDoc" is a javax.activation.DataHandler.

byte[] buffer = org.apache.commons.io.IOUtils.toByteArray(ciDoc.getInputStream());

org.apache.commons.io.FileUtils.writeByteArrayToFile(fileItemUCM.getFile(), buffer);

item.setFile(fileItemUCM.getFile());

The fileItemUCM.getFile() is always damaged, really is nothing writing into it.


Solution

  • Finally I solved this issue. The trouble happened because in the server side someone enables the MTOM way to tranfer information. So modifing spring webservicestemplates for working with MTOM resolve my problem.

    thanks,