这是来自HitHub的代码,用于我的学习目的。我尝试在eclipse中运行它并得到如下错误:
Exception in thread "main" org.matsim.core.utils.io.UncheckedIOException: java.io.FileNotFoundException: args[0]
at org.matsim.core.utils.io.IOUtils.getBufferedReader(IOUtils.java:125)
at org.matsim.core.utils.io.IOUtils.getBufferedReader(IOUtils.java:72)
at org.matsim.core.utils.io.MatsimXmlParser.parse(MatsimXmlParser.java:147)
at org.matsim.core.config.ConfigUtils.loadConfig(ConfigUtils.java:59)
at test1.RunCarsharing.main(RunCarsharing.java:23)
Caused by: java.io.FileNotFoundException: args[0]
... 5 more
主程序如下:
public class RunCarsharing {
public static void main(String[] args) {
Logger.getLogger( "org.matsim.core.controler.Injector" ).setLevel(Level.OFF);
final Config config = ConfigUtils.loadConfig(args[0]);
CarsharingUtils.addConfigModules(config);
final Scenario sc = ScenarioUtils.loadScenario(config);
final Controler controler = new Controler( sc );
installCarSharing(controler);
controler.run();
}
public static void installCarSharing(final Controler controler) {
Scenario sc = controler.getScenario() ;
controler.addOverridingModule( new AbstractModule() {
@Override
public void install() {
this.addPlanStrategyBinding("RandomTripToCarsharingStrategy").to( RandomTripToCarsharingStrategy.class ) ;
this.addPlanStrategyBinding("CarsharingSubtourModeChoiceStrategy").to( CarsharingSubtourModeChoiceStrategy.class ) ;
}
});
controler.addOverridingModule(new AbstractModule() {
@Override
public void install() {
bindMobsim().toProvider( CarsharingQsimFactory.class );
}
});
controler.setTripRouterFactory(CarsharingUtils.createTripRouterFactory(sc));
//setting up the scoring function factory, inside different scoring functions are set-up
controler.setScoringFunctionFactory(new CarsharingScoringFunctionFactory( sc.getConfig(), sc.getNetwork()));
final CarsharingConfigGroup csConfig = (CarsharingConfigGroup) controler.getConfig().getModule(CarsharingConfigGroup.GROUP_NAME);
controler.addControlerListener(new CarsharingListener(controler,
csConfig.getStatsWriterFrequency() ) ) ;
}
}
答案 0 :(得分:0)
如果代码和堆栈跟踪是准确的,那么获取该异常消息的唯一方法是,如果有人试图打开文件名为"args[0]"
的文件。