Examples

Binary File Hex Dump Example

알 수 없는 사용자 2008. 7. 24. 15:27

package com.izeye.tool.hexdump;

import java.io.*;

public class HexDump {
 public static void main(String[] args) {
  String filename = args[0];
 
  try {
   FileInputStream fis = new FileInputStream(filename);
   int data;
   while ((data = fis.read()) != -1) {
    System.out.print(Integer.toHexString(data).toUpperCase() + " ");
   }
  } catch (FileNotFoundException e) {
   System.err.println(e);
  } catch (IOException e) {
   System.err.println(e);
  }
 }
}