console.getHistory().flushBuffer();
} catch (final Exception e) {
}
try {
final BufferedWriter writer = new BufferedWriter(new FileWriter(queryHistoryFile));
final SAXSerializer serializer = (SAXSerializer) SerializerPool.getInstance().borrowObject(SAXSerializer.class);
serializer.setOutput(writer, null);
int p = 0;
if (queryHistory.size() > 20) {
p = queryHistory.size() - 20;
}
final AttributesImpl attrs = new AttributesImpl();
serializer.startDocument();
serializer.startElement("", "history", "history", attrs);
for(final ListIterator<String> i = queryHistory.listIterator(p); i.hasNext(); ) {
serializer.startElement("", "query", "query", attrs);
final String next = i.next();
serializer.characters(next.toCharArray(), 0, next.length());
serializer.endElement("", "query", "query");
}
serializer.endElement("", "history", "history");
serializer.endDocument();
writer.close();
SerializerPool.getInstance().returnObject(serializer);
} catch (final IOException e) {
System.err.println("IO error while writing query history.");
} catch (final SAXException e) {