How do I trim a file extension from a String in Java?

This is the sort of code that we shouldn’t be doing ourselves. Use libraries for the mundane stuff, save your brain for the hard stuff.

In this case, I recommend using FilenameUtils.removeExtension() from Apache Commons IO

Leave a Comment