I have been using:
URLConnection uc = url.openConnection();
String origMimeType = uc.getContentType();
to get the mimetype of a file from url. It will extract the mime type of the file based on JAVA_HOME/lib/content-type
But now, I need an opposite method to get the file extension back from the file mime type.
Is there a method available to do this?
I saw this post:
But it's suggesting loading another "mimetype to file extension conversion" reference list. I would like to use the one I've used to be consistent which is the content-type.properties file.
If possible, I would avoid manually parse the file.
Here is part of the content-types.properties file:
description=Generic Binary Stream;\
description=Adobe PDF Format;\
Thanks a lot!