public static byte[] loadFileIntoByteArray(String path) throws IOException { RandomAccessFile f = new RandomAccessFile(path, "r"); try { byte[] data = new byte[(int) f.length()]; f.readFully(data); return data; } finally { f.close(); } }