Java gets the file extension without substring
•
Java
How to get a file extension in Java without using stupid lastIndexOf ('.') and so on?
Solution
The Apache commons library has filenameutils getExtension().
You can view the source code from here and filenameutils
At least look at their implementation It's very simple. They handle dir correctly Ext / file, and handle files like file tar. GZ such things, if you want to extract tar. GZ, not just GZ, you need a special situation
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码