@Override public void notifyShutdown(ShutdownEvent event) { try { this.writer.close(); } catch (IOException e) { throw new UncheckedIOException( e ); } }
@Override public void notifyBeforeMobsim(BeforeMobsimEvent event) { try { this.writer.flush(); } catch (IOException e) { throw new UncheckedIOException( e ); } } }
public void write(char c) { if (writer != null) try { writer.write(c); } catch (IOException e) { throw new UncheckedIOException(e); } }
@Override public void close() { try { writer.close(); } catch (IOException e) { throw new UncheckedIOException(e); } }
@Override public void flush() { try { writer.flush(); } catch (IOException e) { throw new UncheckedIOException(e); } }
@Override public void notifyShutdown(ShutdownEvent event) { try { this.writer.close(); } catch (IOException e) { throw new UncheckedIOException( e ); } }
@Override public void notifyBeforeMobsim(BeforeMobsimEvent event) { try { this.writer.flush(); } catch (IOException e) { throw new UncheckedIOException( e ); } } }
public void write(String s) { if (writer != null) { try { writer.write(s); } catch (IOException e) { System.err.println("writer was not initialized yet!"); throw new UncheckedIOException(e); } } }
@Override void endConfig(final BufferedWriter out) throws UncheckedIOException { try { out.write("</config>"); out.write(this.newline); } catch (IOException e) { throw new UncheckedIOException(e); } }
public static InputStream getInputStream(URL url) throws UncheckedIOException { try { if (url.getFile().endsWith(".gz")) { return new GZIPInputStream(url.openStream()); } else { return url.openStream(); } } catch (IOException e) { throw new UncheckedIOException(e); } }
private XMLSignalSystems getXmlSignalSystems(InputStream stream) { try { JAXBContext jc = JAXBContext.newInstance(org.matsim.jaxb.signalsystems20.ObjectFactory.class); Unmarshaller u = jc.createUnmarshaller(); u.setSchema(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(getClass().getResource("/dtd/signalSystems_v2.0.xsd"))); return (XMLSignalSystems) u.unmarshal(stream); } catch (JAXBException | SAXException e) { throw new UncheckedIOException(e); } } }
@Override public void close() { try { super.close(); } catch (IOException e) { throw new UncheckedIOException(e); } } }
public final void writeStream(final java.io.Writer writer) { try { this.writer = new BufferedWriter(writer); write(); this.writer.flush(); this.writer = null; } catch (IOException e) { throw new UncheckedIOException(e); } }
@Override public final void readFile( String filename ){ log.info("starting unmarshalling " + filename); try ( InputStream stream = IOUtils.getInputStream(filename )){ readStream(stream); } catch ( IOException e) { throw new UncheckedIOException(e); } }
public void write(OutputStream stream) throws UncheckedIOException { this.openOutputStream(stream); try { writeData(); } catch (IOException e) { throw new UncheckedIOException(e); } }
public void write(final String filename) throws UncheckedIOException { this.openFile(filename); try { writeData(); } catch (IOException e) { throw new UncheckedIOException(e); } }
public final void writeStream(final java.io.Writer writer, final String newline) { try { final String formerNewLine = this.handler.setNewline(newline); this.writer = new BufferedWriter(writer); write(); this.writer.flush(); this.writer = null; this.handler.setNewline( formerNewLine ); } catch (IOException e) { throw new UncheckedIOException(e); } }
private final void writePerson(final Person person) { try { if ((this.write_person_fraction < 1.0) && (MatsimRandom.getRandom().nextDouble() >= this.write_person_fraction)) { return; } this.handler.writePerson(person, this.writer); counter.incCounter(); } catch (IOException e) { throw new UncheckedIOException(e); } }
public final void writePerson(final Person person) { try { if ((this.write_person_fraction < 1.0) && (MatsimRandom.getRandom().nextDouble() >= this.write_person_fraction)) { return; } this.handler.writePerson(person, matsimWriter.getWriter()); counter.incCounter(); } catch (IOException e) { throw new UncheckedIOException(e); } }
public static List<String[]> readFile(String file, char separator) { try (CSVReader reader = new CSVReaderBuilder(IOUtils.getBufferedReader(file)) .withCSVParser(new CSVParserBuilder().withSeparator(separator).build()).build()) { return reader.readAll(); } catch (IOException e) { throw new UncheckedIOException(e); } } }