Use isEmpty().
diff --git a/src/main/java/org/apache/commons/exec/CommandLine.java b/src/main/java/org/apache/commons/exec/CommandLine.java
index 5a1882c..fad7e3d 100644
--- a/src/main/java/org/apache/commons/exec/CommandLine.java
+++ b/src/main/java/org/apache/commons/exec/CommandLine.java
@@ -78,7 +78,7 @@
if (line == null) {
throw new IllegalArgumentException("Command line can not be null");
- } else if (line.trim().length() == 0) {
+ } else if (line.trim().isEmpty()) {
throw new IllegalArgumentException("Command line can not be empty");
} else {
final String[] tmp = translateCommandline(line);
@@ -334,7 +334,7 @@
* parameter results in a zero sized array
*/
private static String[] translateCommandline(final String toProcess) {
- if (toProcess == null || toProcess.length() == 0) {
+ if (toProcess == null || toProcess.isEmpty()) {
// no command? no string
return new String[0];
}
@@ -410,7 +410,7 @@
private String toCleanExecutable(final String dirtyExecutable) {
if (dirtyExecutable == null) {
throw new IllegalArgumentException("Executable can not be null");
- } else if (dirtyExecutable.trim().length() == 0) {
+ } else if (dirtyExecutable.trim().isEmpty()) {
throw new IllegalArgumentException("Executable can not be empty");
} else {
return StringUtils.fixFileSeparatorChar(dirtyExecutable);
diff --git a/src/main/java/org/apache/commons/exec/util/StringUtils.java b/src/main/java/org/apache/commons/exec/util/StringUtils.java
index b8fb1e9..c2e2a68 100644
--- a/src/main/java/org/apache/commons/exec/util/StringUtils.java
+++ b/src/main/java/org/apache/commons/exec/util/StringUtils.java
@@ -70,7 +70,7 @@
final StringBuffer argBuf = new StringBuffer();
- if (argStr == null || argStr.length() == 0) {
+ if (argStr == null || argStr.isEmpty()) {
return argBuf;
}