示例#1
0
文件: Apps.java 项目: dpharris/JMRI
 /**
  * Set up the configuration file name at startup.
  *
  * <p>The Configuration File name variable holds the name used to load the configuration file
  * during later startup processing. Applications invoke this method to handle the usual startup
  * hierarchy:
  *
  * <UL>
  *   <LI>If an absolute filename was provided on the command line, use it
  *   <LI>If a filename was provided that's not absolute, consider it to be in the preferences
  *       directory
  *   <LI>If no filename provided, use a default name (that's application specific)
  * </UL>
  *
  * This name will be used for reading and writing the preferences. It need not exist when the
  * program first starts up. This name may be proceeded with <em>config=</em> and may not contain
  * the equals sign (=).
  *
  * @param def Default value if no other is provided
  * @param args Argument array from the main routine
  */
 protected static void setConfigFilename(String def, String[] args) {
   // save the configuration filename if present on the command line
   if (args.length >= 1 && args[0] != null && !args[0].contains("=")) {
     def = args[0];
     log.debug("Config file was specified as: {}", args[0]);
   }
   for (String arg : args) {
     String[] split = arg.split("=", 2);
     if (split[0].equalsIgnoreCase("config")) {
       def = split[1];
       log.debug("Config file was specified as: {}", arg);
     }
   }
   Apps.configFilename = def;
   setJmriSystemProperty("configFilename", def);
 }