Read file as stream, set response and close stream does not work

Hello,

In a REST API, I have created a Java service to read file as InputStream. I set InputStream as output variable of Java service.
Now I map InputStream to responseStream of pub.flow:setResponse2.
After this I use pub.io:close to close the InputStream.

When I call this REST API from browser I get stream closed error. Even though I am closing the stream after calling setResponse2.
Removing pub.io:close works fine but it leaves the file locked.

Thanks,
Kalpshekhar

Hi Kalpshekhar,
in Java, nothing will be read from the open stream unless you tell Java to do so. You will find plenty of information regarding this topic in the Internet (e.g. https://www.baeldung.com/reading-file-in-java).

Best regards,
Marcus