String myPath = ConfigurationManager.getProperty("dspace.dir") + File.separator + "config" + File.separator + "mediafilter.cfg";   System.out.println("Using configuration in " + myPath);
    public static void main(String[] argv) throws Exception    {        // set headless for non-gui workstations        System.setProperty("java.awt.headless", "true");        // create an options object and populate it        CommandLineParser parser = new PosixParser();        Options options = new Options();        options.addOption("v", "verbose", false,                "print all extracted text and other details to STDOUT");        options.addOption("f", "force", false,                "force all bitstreams to be processed");        options.addOption("n", "noindex", false,                "do NOT re-create search index after filtering bitstreams");        options.addOption("h", "help", false, "help");        CommandLine line = parser.parse(options, argv);        if (line.hasOption('h'))        {            HelpFormatter myhelp = new HelpFormatter();            myhelp.printHelp("MediaFilter\n", options);            System.exit(0);        }        if (line.hasOption('v'))        {            isVerbose = true;        }        if (line.hasOption('n'))        {            createIndex = false;        }        if (line.hasOption('f'))        {            isForce = true;        }        // get path to config file        String myPath = ConfigurationManager.getProperty("dspace.dir")                + File.separator + "config" + File.separator                + "mediafilter.cfg";        // format name, classname        System.out.println("Using configuration in " + myPath);        Context c = null;        try        {            c = new Context();            // have to be super-user to do the filtering            c.setIgnoreAuthorization(true);            // read in the mediafilter.cfg file, store in HashMap            BufferedReader is = new BufferedReader(new FileReader(myPath));            String myLine = null;            while ((myLine = is.readLine()) != null)            {                // skip any lines beginning with #                if (myLine.indexOf("#") == 0)                {                    continue;                }                // no comment, so try and parse line                StringTokenizer st = new StringTokenizer(myLine);                // has to have at least 2 tokens                if (st.countTokens() >= 2)                {                    String[] tokens = new String[st.countTokens()];                    // grab all tokens and stuff in array                    for (int i = 0; i < tokens.length; i++)                    {                        tokens[i] = st.nextToken();                    }                    // class is the last token                    String myClass = tokens[tokens.length - 1];                    String myFormat = tokens[0];                    // everything else is the format                    for (int i = 1; i < (tokens.length - 1); i++)                    {                        myFormat = myFormat + " " + tokens[i];                    }                    System.out.println("Format: '" + myFormat                            + "' Filtering Class: '" + myClass + "'");                    // now convert format name to a format ID (int) for the hash                    // key                    int formatID = BitstreamFormat.findByShortDescription(c,                            myFormat).getID();                    filterNames.put(new Integer(formatID), myClass);                }            }            is.close();            // now apply the filters            applyFiltersAllItems(c);            // create search index?            if (createIndex)            {                System.out.println("Creating search index:");                DSIndexer.createIndex(c);            }            c.complete();            c = null;        }        finally        {            if (c != null)            {                c.abort();            }        }    }