Start with something like
Config config = ConfigUtils.createConfig(); Scenario sc = ScenarioUtils.createScenario(config);
From there on, you can use command completion on sc and anything else that you have found in order to find out about additional commands.
At the end, you write to file by
MatsimWriter popWriter = new org.matsim.api.core.v01.population.PopulationWriter(population) ; popWriter.write( filename )
Config config = ConfigUtils.createConfig();
Scenario sc = ScenarioUtils.createScenario(config);
Network network = sc.getNetwork();
Population population = sc.getPopulation();
PopulationFactory populationFactory = population.getFactory(); // (*)
Person person = populationFactory.createPerson(sc.createId("someId"));
population.addPerson(person) ;
Plan plan = populationFactory.createPlan();
// do something with the plan, fill it with Activities and Legs.
person.addPlan(plan);
MatsimWriter popWriter = new org.matsim.api.core.v01.population.PopulationWriter(population, network);
popWriter.write(filename);It is important to note the (*) syntax, i.e. the creational methods are in the factory.
An example is under src/tutorial/programming/example8DemandGeneration. This should also be used to obtain hints with respect to the correct syntax ... since it is automatically part of all refactorings.