AFAIK that is not possible directly because Mendix files are actually stored in AWS instead of the local file system. What you can do is copy the Mendix file content to a local temp file and use that instead. See this great post by Erwin for more details https://forum.mendix.com/link/questions/8573
To create a temporary file in java see https://www.tutorialspoint.com/java/io/file_createtempfile_directory.htm
Note that temporary files are not automatically removed, you would need to delete them manually after you are done with them.
Hope this helps