Source code: com/chaoswg/xtc4y/util/ByteCodePrinter.java
1 //$Header: /cvsroot/xtc4y/xtc4y/src/com/chaoswg/xtc4y/util/ByteCodePrinter.java,v 1.1 2003/08/26 12:52:50 toggm Exp $
2 /******************************************************************************
3 * XTC4y - eXtreme Testing Collection 4 you *
4 * -------------------------------------------------------------------------- *
5 * URL: http://www.chaoswg.com/xtc4y *
6 * Author: Mike Toggweiler (2.dog@gmx.ch) *
7 * *
8 * Last Updated: $Date: 2003/08/26 12:52:50 $, by $Author: toggm $ *
9 * Version: $Revision: 1.1 $ *
10 * -------------------------------------------------------------------------- *
11 * COPYRIGHT: (c) 2003 by Mike Toggweiler *
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 *****************************************************************************/
18 package com.chaoswg.xtc4y.util;
19
20 import java.io.FileInputStream;
21 import java.io.IOException;
22
23 /**
24 * This class is used to print out the bytecode of a classfile
25 * @author Mike Toggweiler
26 **/
27 public class ByteCodePrinter {
28
29 public ByteCodePrinter(String file) throws IOException {
30 FileInputStream fis = new FileInputStream(file);
31 int b;
32 String empty = " ";
33 System.out.println("Bytecode of file:" + file);
34 while ((b = fis.read()) != -1) {
35 String bs = String.valueOf(b);
36 System.out.print(bs + empty.substring(0, 5-bs.length()));
37 }
38 fis.close();
39 }
40
41 public static void main(String[] argv) throws IOException {
42 if (argv.length < 1) {
43 System.out.println("Please specify file to print");
44 System.exit(-1);
45 }
46 new ByteCodePrinter(argv[0]);
47 }
48 }