I have used this with success. Hope it helps
FileDocument document = FileDocument.create(context);
InputStream inputStream = IOUtils.toInputStream("<xml></xml>");
Core.storeFileDocumentContent(context, document.getMendixObject(), inputStream);
I use the system context
private IContext context = Core.createSystemContext();