How to convert Chemistry ContentStream object into byte array (byte[])?

1k Views Asked by At

I am trying to convert a cmis Document to a byte stream to be in sync with a project specific request constructor, which uses byte[], converting from a File type object is OK, but converting the cmis document is something I am not getting.

1

There are 1 best solutions below

0
On

If you are using Java 9 or later, you can something like this.

Document doc = ...;
InputStream stream = doc.getContentStream().getStream();
byte[] bytes = null;
try {
    bytes = stream.readAllBytes();
}
finally {
   stream.close();
}