You need to use the storeFileDocumentContent method in the Core API to store the contents of an InputStream (not an OutputStream) into a FileDocument.
https://apidocs.rnd.mendix.com/8/runtime/com/mendix/core/Core.html#storeFileDocumentContent(com.mendix.systemwideinterfaces.core.IContext,com.mendix.systemwideinterfaces.core.IMendixObject,java.lang.String,java.io.InputStream)
You will need to have created a FileDocument object beforehand to pass into this call. You can pass this into your Java Action, or create one using the generated proxy classes. Once this has been stored, you can use the getMendixObject() method on the Mendix FileDocument object to return it from your Java Action.
Hope this helps.