ensureDirectoryFor(outFile);
log("Parsing file " + inFile + " to " + outFile, Project.MSG_INFO);
ObjectInputStream in = new ObjectInputStream(new FileInputStream(parsertableFile));
EventQueue queue = parser.parse((ParserTable)in.readObject(), new FileInputStream(inFile), encoding);
in.close();
OutputFormat format = new OutputFormat(Method.XML, "ASCII", indent); // Serialize DOM
if (indent)
{
format.setIndenting(true);
format.setIndent(1);
}
else
format.setPreserveSpace(true);
StringWriter stringOut = new StringWriter(); // Writer will be a String
XMLSerializer serial = new XMLSerializer(stringOut, format);
SAXEventAdapter adapter = new SAXEventAdapter(serial.asContentHandler(), ignorableTokens, false);
adapter.enableLogging(new AntLogger(this, msgLevel));
queue.fireEvents(adapter);
FileOutputStream outputstream = new FileOutputStream(outFile);
PrintWriter printstream = new PrintWriter(outputstream);
printstream.println(stringOut.toString());