public static ConfigParser getParserForName ( String name ) { int lastDot = name . lastIndexOf ( "." ) ; if ( lastDot < 0 ) { throw new ConfigException ( "No file suffix in name: " + name ) ; } String suffix = name . substring ( lastDot ) ; switch ( suffix . toLowerCase ( ) ) { case ".toml" : case ".ini" : return new TomlConfigParser ( ) ; case ".json" : return new JsonConfigParser ( ) ; case ".properties" : return new PropertiesConfigParser ( ) ; default : throw new ConfigException ( "Unknown config file suffix: " + suffix ) ; } }
Get the parser that matches the file format associated with the given file suffix . The given string must include the last . in order to be valid .