Skip to content

Commit c5ca539

Browse files
author
Gary Gregory
committed
Reuse IOUtils.length(Object[]).
1 parent 012775a commit c5ca539

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/main/java/org/apache/commons/io/FileUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2936,7 +2936,7 @@ public static File toFile(final URL url) {
29362936
* @since 1.1
29372937
*/
29382938
public static File[] toFiles(final URL... urls) {
2939-
if (urls == null || urls.length == 0) {
2939+
if (IOUtils.length(urls) == 0) {
29402940
return EMPTY_FILE_ARRAY;
29412941
}
29422942
final File[] files = new File[urls.length];

src/main/java/org/apache/commons/io/file/StandardDeleteOption.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.apache.commons.io.file;
1919

20+
import org.apache.commons.io.IOUtils;
21+
2022
/**
2123
* Defines the standard delete options.
2224
*
@@ -38,7 +40,7 @@ public enum StandardDeleteOption implements DeleteOption {
3840
* @return true if the given options contain {@link StandardDeleteOption#OVERRIDE_READ_ONLY}.
3941
*/
4042
public static boolean overrideReadOnly(final DeleteOption[] options) {
41-
if (options == null || options.length == 0) {
43+
if (IOUtils.length(options) == 0) {
4244
return false;
4345
}
4446
for (final DeleteOption deleteOption : options) {

src/main/java/org/apache/commons/io/filefilter/EmptyFileFilter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import java.nio.file.attribute.BasicFileAttributes;
2626
import java.util.stream.Stream;
2727

28+
import org.apache.commons.io.IOUtils;
29+
2830
/**
2931
* This filter accepts files or directories that are empty.
3032
* <p>
@@ -101,7 +103,7 @@ protected EmptyFileFilter() {
101103
public boolean accept(final File file) {
102104
if (file.isDirectory()) {
103105
final File[] files = file.listFiles();
104-
return files == null || files.length == 0;
106+
return IOUtils.length(files) == 0;
105107
}
106108
return file.length() == 0;
107109
}

0 commit comments

Comments
 (0)