diff --git a/client/src/com/aerospike/client/util/Util.java b/client/src/com/aerospike/client/util/Util.java index 2271a5a60..777e77caf 100644 --- a/client/src/com/aerospike/client/util/Util.java +++ b/client/src/com/aerospike/client/util/Util.java @@ -73,23 +73,12 @@ public static String getStackTrace(Throwable e) { } public static byte[] readFile(File file) { - try { - byte[] bytes = new byte[(int)file.length()]; - - try (FileInputStream in = new FileInputStream(file)) { - int pos = 0; - int len = 0; - - while (pos < bytes.length) { - len = in.read(bytes, pos, bytes.length - pos); - pos += len; - } - return bytes; - } - } - catch (Throwable e) { - throw new AerospikeException("Failed to read " + file.getAbsolutePath(), e); - } + try (FileInputStream fis = new FileInputStream(file)) { + return fis.readAllBytes(); + } + catch (Throwable e) { + throw new AerospikeException("Failed to read " + file.getAbsolutePath(), e); + } } public static byte[] readResource(ClassLoader resourceLoader, String resourcePath) {