Here is the one liner that appends the string with a prefix if the string doesn’t have a prefix
1 2 |
String newString = oldString.startsWith("someprefix") ? oldString : "someprefix" + oldString; |
A blog about Java. Examples for Java design patterns, Java core examples, web frameworks.
Here is the one liner that appends the string with a prefix if the string doesn’t have a prefix
1 2 |
String newString = oldString.startsWith("someprefix") ? oldString : "someprefix" + oldString; |