import java.io.FileInputStream; public class Main { public static void main(String[] argv) throws Exception { FileInputStream fin = new FileInputStream("text.txt"); int len; byte data[] = new byte[16]; // Read bytes until EOF is encountered. do { len = fin.read(data); for (int j = 0; j < len; j++) System.out.printf("%02X ", data[j]); } while (len != -1); } }