public static void main(String[] args) throws Exception { // convert BEAST 2 XML to BEAST JSON file XMLParser parser = new XMLParser(); BEASTInterface beastObject = parser.parseFile(new File(args[0])); String JSONFile = args[0].replace(".xml", ".json"); PrintStream out; if (JSONFile.endsWith(".json")) { out = new PrintStream(new File(JSONFile)); } else { out = System.out; } JSONProducer writer = new JSONProducer(); String JSON = writer.toJSON(beastObject); out.println(JSON); out.close(); }