Apache Commons Lang is an API which simplifies the Java development by providing easy to use methods for the classes in java.lang package. This API provides a host of helper utilities, notably String manipulation methods, basic numerical methods, object reflection, concurrency, creation and serialization and System properties. Additionally it contains basic enhancements to java.util.Date and a series of utilities dedicated to help with building methods, such as hashCode, toString and equals.
Here goes a common example for String manipulation:
Lets take a String comparison example:
The classical way we perfom String comparison is:
void stringTest(String test) {
if((test != null) && test.equalsIgnoreCase("test") {
// do something
}
}
Now lets see how Apache LangUtil is gonna help the above scenario:
void stringTest(String test) {
if(StringUtils.equalsIgnoreCase(test, "test") {
// do something
}
}
The advantage of using the second method is that Stringutils will take care of null check and comparison, so that u dont have to really worry about NullPointerException. A lot of pretty utility methods are available, not only it ends with String comparison but to handle Object, Numbers, Date etc.
You can download the latest version of the API from here
Hope it helps you out. All the best!!!
Here goes a common example for String manipulation:
Lets take a String comparison example:
The classical way we perfom String comparison is:
void stringTest(String test) {
if((test != null) && test.equalsIgnoreCase("test") {
// do something
}
}
Now lets see how Apache LangUtil is gonna help the above scenario:
void stringTest(String test) {
if(StringUtils.equalsIgnoreCase(test, "test") {
// do something
}
}
The advantage of using the second method is that Stringutils will take care of null check and comparison, so that u dont have to really worry about NullPointerException. A lot of pretty utility methods are available, not only it ends with String comparison but to handle Object, Numbers, Date etc.
You can download the latest version of the API from here
Hope it helps you out. All the best!!!