You need to use the storeFileDocumentContent method in the Core API to store the contents of an InputStream (not an OutputStream) into a FileDocument.
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.