public static void main(String[] args) throws Exception {
        if (args.length == 0) {
            System.out.println("DisassemblyTool [-f <format style>] <file or class name>");
            System.out.println();
            System.out.println("The format style may be \"assembly\" (the default) or \"builder\"");
            return;
        }

        String style;
        String name;

        if ("-f".equals(args[0])) {
            style = args[1];
            name = args[2];
        } else {
            style = "assembly";
            name = args[0];
        }

        ClassFileDataLoader loader;
        InputStream in;

        try {
            final File file = new File(name);
            in = new FileInputStream(file);
            loader = new ClassFileDataLoader() {
                public InputStream getClassData(String name)
                    throws IOException
                {
                    name = name.substring(name.lastIndexOf('.') + 1);
                    File f = new File(file.getParentFile(), name + ".class");

                    if (f.exists()) {
                        return new FileInputStream(f);
                    }

                    return null;
                }
            };
        } catch (FileNotFoundException e) {
            if (name.endsWith(".class")) {
                System.err.println(e);
                return;
            }

            loader = new ResourceClassFileDataLoader();
            in = loader.getClassData(name);

            if (in == null) {
                System.err.println(e);
                return;
            }
        }

        in = new BufferedInputStream(in);
        ClassFile cf = ClassFile.readFrom(in, loader, null);

        PrintWriter out = new PrintWriter(System.out);

        Printer p;
        if (style == null || style.equals("assembly")) {
            p = new AssemblyStylePrinter();
        } else if (style.equals("builder")) {
            p = new BuilderStylePrinter();
        } else {
            System.err.println("Unknown format style: " + style);
            return;
        }

        p.disassemble(cf, out);

        out.flush();
    }