Skip to content

Commit

Permalink
Update Bytes.java
Browse files Browse the repository at this point in the history
Restored old logic
  • Loading branch information
tweimer authored Nov 17, 2024
1 parent 3dce2db commit a6e5dc3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/com/mergebase/log4j/Bytes.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ public class Bytes {
public static final int LAST_READ_KEY = 1;

public static byte[] fileToBytes(File f) {
try {
return Files.readAllBytes(f.toPath());
try (FileInputStream fin = new FileInputStream(f)) {
if (f.length() <= 32768) {
byte[] buf = new byte[(int) f.length()];
fill(buf, 0, fin);
return buf;
} else {
return streamToBytes(fin, false);
}
} catch (IOException ioe) {
throw new UncheckedIOException("Failed to read file [" + f.getName() + "] " + ioe, ioe);
}
Expand Down

0 comments on commit a6e5dc3

Please sign in to comment.