Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package odyssey; import java.io.File; import org.apache.commons.configuration2.Configuration; import org.apache.commons.configuration2.builder.fluent.Configurations; /** * * @author pat */ public class Odyssey { /** * @param args the command line arguments */ public static void main(String[] args) { Configurations configs = new Configurations(); if (0 < args.length) { String propFileName = args[0]; File props = new File(propFileName); if (props.exists()) { try { Configuration config = configs.properties(props); System.out.println("Using properties file: " + props); System.out.println("Prop1: " + config.getString("test.property1")); System.out.println("Prop1: " + config.getString("test.property2")); } catch (Exception e) { System.out.println("Error: " + e.toString()); } } else { System.out.println("Error: The specified properties file does not exist: " + propFileName); } } else { System.out.println("Error: A required properties file was not specified."); } } }