21 package org.matsim.core.events.algorithms;
23 import org.apache.logging.log4j.LogManager;
24 import org.apache.logging.log4j.Logger;
29 import java.io.BufferedWriter;
30 import java.io.IOException;
31 import java.io.OutputStream;
32 import java.io.OutputStreamWriter;
33 import java.io.UncheckedIOException;
34 import java.nio.charset.StandardCharsets;
39 private final BufferedWriter
out;
44 private final ThreadLocal<StringBuilder>
stringBuilder = ThreadLocal.withInitial(StringBuilder::new);
57 this.out =
new BufferedWriter(
new OutputStreamWriter(stream, StandardCharsets.UTF_8));
63 this.out.write(
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<events version=\"1.0\">\n");
64 }
catch (IOException e) {
65 throw new UncheckedIOException(e);
72 this.out.write(
"</events>");
78 }
catch (IOException e) {
79 throw new UncheckedIOException(e);
84 public void reset(
final int iter) {
90 StringBuilder b = stringBuilder.get();
96 }
catch (IOException e) {
97 LOG.error(e.getMessage(), e);
final ThreadLocal< StringBuilder > stringBuilder
void reset(final int iter)
static BufferedWriter getBufferedWriter(URL url, Charset charset, boolean append)
void handleEvent(final Event event)
EventWriterXML(final String outfilename)
EventWriterXML(final OutputStream stream)