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
More Related Contents:
- Need some advice on split() method in Java [closed]
- StringBuilder vs String concatenation in toString() in Java
- Sort on a string that may contain a number
- How to get a list of current open windows/process with Java?
- How to get PID of process I’ve just started within java program?
- Getting strange output when printing result of a string comparison
- Why is String immutable in Java?
- How to remove duplicate white spaces in string using Java?
- Isn’t the size of character in Java 2 bytes?
- java.lang.IllegalStateException: Scanner closed
- How to compare character ignoring case in primitive types
- Java String Scanner input does not wait for info, moves directly to next statement. How to wait for info? [duplicate]
- Converting an int to a binary string representation in Java?
- Difference between “char” and “String” in Java
- Fatal Error: Invalid Layout of java.lang.String at value
- String replacement in java, similar to a velocity template
- String concatenation containing Arabic and Western characters
- How to center a string using String.format?
- Read String line by line
- How to check a string against null in java?
- Converting a sentence string to a string array of words in Java
- How to get the last characters in a String in Java, regardless of String size
- What is the character encoding of String in Java?
- How to create variables dynamically in Java? [closed]
- substring index range
- How to replace a substring of a string [duplicate]
- How to replace � in a string
- How do I get the last character of a string?
- Is it possible in Java to override ‘toString’ for an Objects array?
- split string only on first instance – java