There is a storeFileDocumenContent method that takes the filename as a string parameter, it would have no way of knowing the filename from the inputstream itself.
Can you tell what it is that is going wrong? Do you get an exception, does the filename not show up, will the file not load?
By the way, I would not recommend throwing a CoreException since this is what is used by the runtime (business server) itself. In this case I would probably throw a UserException
Two things. First of all, you can pass the name of the file to the core api as well:
public static void storeFileDocumentContent(IContext context, IMendixObject fileDocument, String fileName, InputStream inputStream)
secondly, you pasted a little bit of code to determine the lastIndex of ".", but you're not using any of that you your java action? If you have a file object you can always call getName on it, btw.