org.matsim.core.utils.io.IOUtils.getPrintStream()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中org.matsim.core.utils.io.IOUtils.getPrintStream()方法的一些代码示例,展示了IOUtils.getPrintStream()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.getPrintStream()方法的具体详情如下:
包路径:org.matsim.core.utils.io.IOUtils
类名称:IOUtils
方法名:getPrintStream

IOUtils.getPrintStream介绍

[英]Copy of getOutputStream and then changed to correspond to the PrintStream signature. Device to hopefully reduce FindBugs warnings. kai, may'17
[中]getOutputStream的副本,然后更改为与PrintStream签名相对应。希望减少FindBugs警告的设备。kai,5月17日

代码示例

代码示例来源:origin: matsim-org/matsim

/**
 * Writes the gathered data tab-separated into a text file.
 *
 * @param filename The name of a file where to write the gathered data.
 */
public void write(final String filename) {
  try (PrintStream stream = IOUtils.getPrintStream(filename) ) {
    write(stream);
  }
}

代码示例来源:origin: io.github.agentsoz/bdi-matsim

void write(double time, Id<Link> linkId, Coord coord, double speed ) {
  if (writer == null) {
    final String filename = config.controler().getOutputDirectory() + "/output_disruptionCoords.txt.gz";
    log.warn("writing disruption data to " + filename);
    writer = IOUtils.getPrintStream(filename);
    writer.println("time\tlinkId\tx\ty\tnewSpeed");
  }
  // can't do this earlier since the output directories are not yet prepared by the controler.  kai, dec'17
  // Since we are memorizing the records towards the very end, could as well just open and close the writer there.
  // kai, feb'18
  
  final String str = Time.writeTime(time) + "\t" + linkId + "\t" + coord.getX() + "\t" + coord.getY() + "\t" + speed ;
  // need time in hh:mm:ss since it is to be string-sorted based on that, and otherwise would need numerical sorting.
  // kai, feb'18
  log.info( "disruption data: " + str ) ;
  records.add( str ) ;
  // memorizing the entries towards the very end, since the "begin" and "end" disruption events come together, but I
  // want to have the output sorted by time. kai, feb'18
  
}

代码示例来源:origin: io.github.agentsoz/bdi-matsim

final String filename = config.controler().getOutputDirectory() + "/output_" + name + "Coords.txt.gz";
log.info("writing " + name + " data to " + filename);
writer = IOUtils.getPrintStream(filename);
writer.println("time\tx\ty");

相关文章