package io;
import java.io.*;
import java.util.Scanner;
public class Exercise17_19 {
public static void main(String[] args) throws IOException {
Scanner input = new Scanner(System.in);
System.out.print("Enter a file name: ");
File file = new File(input.nextLine().trim());
if (!file.exists())
System.out.println("No such file exists!");
else {
try(DataInputStream inputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(file)))) {
try {
while (true)
System.out.print(getHex(inputStream.readByte()) + " ");
} catch (EOFException ex) {
}
}
}
}
/** 返回字节的十六进制表示形式 */
public static String getHex(int value) {
return Integer.toHexString(value);
}
}