In Java, given a java.net.URL
or a String
in the form of http://www.example.com/some/path/to/a/file.xml
, what is the easiest way to get the file name, minus the extension? So, in this example, I'm looking for something that returns "file"
.
I can think of several ways to do this, but I'm looking for something that's easy to read and short.
Urls can have parameters in the end, this
I've come up with this:
There are some ways:
Java 7 File I/O:
Apache Commons:
Using Jersey:
Substring: