@NotNull public static byte[] loadFileBytes(@NotNull File file) throws IOException { byte[] bytes; final InputStream stream = new FileInputStream(file); try { final long len = file.length(); if (len < 0) { throw new IOException("File length reported negative, probably doesn't exist"); } if (isTooLarge(len)) { throw new FileTooBigException( "Attempt to load '" + file + "' in memory buffer, file length is " + len + " bytes."); } bytes = loadBytes(stream, (int) len); } finally { stream.close(); } return bytes; }