Skip to content

Commit f281d13

Browse files
author
Gary Gregory
committed
Use NIO for internals.
1 parent eda8101 commit f281d13

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2608,11 +2608,8 @@ public static FileOutputStream openOutputStream(final File file, final boolean a
26082608
* @since 1.1
26092609
*/
26102610
public static byte[] readFileToByteArray(final File file) throws IOException {
2611-
try (InputStream inputStream = openInputStream(file)) {
2612-
final long fileLength = file.length();
2613-
// file.length() may return 0 for system-dependent entities, treat 0 as unknown length - see IO-453
2614-
return fileLength > 0 ? IOUtils.toByteArray(inputStream, fileLength) : IOUtils.toByteArray(inputStream);
2615-
}
2611+
Objects.requireNonNull(file, "file");
2612+
return Files.readAllBytes(file.toPath());
26162613
}
26172614

26182615
/**

0 commit comments

Comments
 (0)