public static byte[] loadBinaryFile(String fileName, int bufSize default defaultBufferedOutputStreamSize()) { try { if (!new File(fileName).exists()) return null; FileInputStream in = new FileInputStream(fileName); byte buf[] = new byte[bufSize]; ByteArrayOutputStream out = new ByteArrayOutputStream(); int l; while (true) { l = in.read(buf); if (l <= 0) break; out.write(buf, 0, l); } in.close(); return out.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } } public static byte[] loadBinaryFile(File file, int bufSize default defaultBufferedOutputStreamSize()) { return loadBinaryFile(file.getPath(), bufSize); }