How to store file in System.FileDocument entity in java action then download same file?

i am genrating excle in javaaction . but i am not able to store  in System.FileDocument entity .can anyone please help with this
1 answers

You could try something like the below:

public void writeData(FileDocument outputDocument, XSSFWorkbook wb) throws Exception
    try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        try (ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) {
            Core.storeFileDocumentContent(context, outputDocument.getMendixObject(), inputStream);

FYI; this has been done numerous times before, please check the Excel Exporter module code as well on how this is done.