BinToHex { public static byte[] readFile(File file) throws IOException { RandomAccessFile f = new RandomAccessFile(file, "r"); try { long longlength = f.length(); int length = (int) longlength; if (length != longlength) throw new IOException("File size >= 2 GB"); byte[] data = new byte[length]; f.readFully(data); return data; } finally { f.close(); } }  static String toHexFromByte(final byte b); static String toHexFromBytes(final byte[] bytes); static byte[] readFile(File file); static void main(final String[] args); final static int BITS_PER_HEX_DIGIT; }
@Test public void testReadFile() throws IOException{ File file=new File("src/test/resources/xmlString3.txt"); byte[] bytes=BinToHex.readFile(file); Assert.assertNotNull(bytes); }