Check out the code from the AppStore App FileHandling https://appstore.home.mendix.com/link/app/63667/. That will get you started.
Take a look at the Community Commons module in the App Store.
There are methods such as StringFromFile in there that do similar things to what you need. The Java source code is available on GitHub for you to download and see how this is done.
https://github.com/mendix/CommunityCommons
In this case it uses getFileDocumentContent from the Mendix Core API to get an InputStream from a FileDocument.