Reuse IOUtils.length(Object[]).
MODIFY
src/main/java/org/apache/commons/io/FileUtils.java
src/main/java/org/apache/commons/io/FileUtils.java
@@ -2936,7 +2936,7 @@ public static File toFile(final URL url) {
* @since 1.1
*/
public static File[] toFiles(final URL... urls) {
- if (urls == null || urls.length == 0) {
+ if (IOUtils.length(urls) == 0) {
return EMPTY_FILE_ARRAY;
}
final File[] files = new File[urls.length];

MODIFY
src/main/java/org/apache/commons/io/file/StandardDeleteOption.java
src/main/java/org/apache/commons/io/file/StandardDeleteOption.java
package org.apache.commons.io.file;
+import org.apache.commons.io.IOUtils;
+
/**
* Defines the standard delete options.
*
* @return true if the given options contain {@link StandardDeleteOption#OVERRIDE_READ_ONLY}.
*/
public static boolean overrideReadOnly(final DeleteOption[] options) {
- if (options == null || options.length == 0) {
+ if (IOUtils.length(options) == 0) {
return false;
}
for (final DeleteOption deleteOption : options) {

MODIFY
src/main/java/org/apache/commons/io/filefilter/EmptyFileFilter.java
src/main/java/org/apache/commons/io/filefilter/EmptyFileFilter.java
import java.nio.file.attribute.BasicFileAttributes;
import java.util.stream.Stream;
+import org.apache.commons.io.IOUtils;
+
/**
* This filter accepts files or directories that are empty.
* <p>
@@ -101,7 +103,7 @@ protected EmptyFileFilter() {
public boolean accept(final File file) {
if (file.isDirectory()) {
final File[] files = file.listFiles();
- return files == null || files.length == 0;
+ return IOUtils.length(files) == 0;
}
return file.length() == 0;
}

Reuse IOUtils.length(Object[]).