I know I can split strings like this
String myString = "foo.bar";
List<String> strings = Arrays.asList(myString.split("."));
But my String looks like 20151221.1051.Test.01.properties
, it can have any number of dots, and I want to remove the .properties
at the end (only by the last dot).
Use myString.lastIndexOf(".")
to get the index of the last dot.
For example, if you are sure that your input String contains at least one dot :
String name = myString.substring(0,myString.lastIndexOf("."));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With