public void setupAssociators() {
logger.debug("IN");
env.setParameter("operation-output", env.getOutputFile());
for(int i = 0; i < associators.size(); i++) {
Associator associator = (Associator)associators.get(i);
TextListener listener = new TextListener() {
public void acceptText(TextEvent e) {
try {
synchronized(this) {
Writer writer = new FileWriter(env.getOutputFile(), true);
writer.write( e.getText().replaceAll("\n", "\r\n"));
writer.flush();
writer.close();
/*
FileOutputStream outputStream = new FileOutputStream(env.getOutputFile(), true);
//outputStream.write(e.getText().getBytes("US-ASCII"));
outputStream.write(e.getText().getBytes("UTF-8"));
outputStream.flush();
outputStream.close();
*/
}
} catch (Throwable t) {
logger.error(t);
throw new RuntimeException("Impossible to save output text on file [" + env.getOutputFile() + "]", t);
}
}
};
associator.addTextListener(listener);
}
logger.debug("OUT");
}