public static void main(String[] args) throws Exception {
        if(args.length < 2) {
            System.out.println("Usage: java JGrep (file or directory) regex");
            System.exit(0);
        }
        Pattern p = Pattern.compile(args[1]);

        if(!(findDir(args[0], p) || findFile(args[0], p))) {
            if(new File(args[0]).listFiles() == null) {
                System.out.println("no such directory: " + args[0]);
                System.exit(0);
            }
            File[] files = new File(args[0]).listFiles();
            System.out.println(args[0] + ": subdir of files: "
                    + Arrays.asList(files));

            for(File f : files) {
                int index = 0;
                Matcher m = p.matcher("");
                for(String line : new TextFile(args[0] + "\\" + f.getName())) {
                    m.reset(line);
                    while(m.find()) {
                        System.out.println(index++ + ": " + m.group() + ": " +
                                m.start());
                    }
                }
                System.out.println();
            }
        }
    }