當前位置: 首頁>>代碼示例>>Java>>正文


Java Properties.propertyNames方法代碼示例

本文整理匯總了Java中java.util.Properties.propertyNames方法的典型用法代碼示例。如果您正苦於以下問題:Java Properties.propertyNames方法的具體用法?Java Properties.propertyNames怎麽用?Java Properties.propertyNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Properties的用法示例。


在下文中一共展示了Properties.propertyNames方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readNameFile

import java.util.Properties; //導入方法依賴的package包/類
/** Reads the given file. Searches the file for the property passed in, and stores all of those properties into a list. Randomly return one of the properties. */
private static String readNameFile(String filePath, String property) throws IOException
{
	InputStreamReader in = new InputStreamReader(NameGenerator.class.getClassLoader().getResourceAsStream("assets/lootslashconquer/names/" + filePath + ".txt"), "UTF-8");
	Properties props = new Properties();
	props.load(in);
	Enumeration<?> e = props.propertyNames();
	List<String> list = Lists.newArrayList();
	
	while(e.hasMoreElements())
	{
		String key = (String) e.nextElement();
		
		if (key != null && key.contains(property))
		{
			list.add(props.getProperty(key));
		}
	}
	
	in.close();
	
	return list.size() > 0 ? list.get((int) (Math.random() * list.size())) : "Error";
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:24,代碼來源:NameGenerator.java

示例2: readTagNames

import java.util.Properties; //導入方法依賴的package包/類
private static void readTagNames() {
    try {
        File jarLocation = new File(Config.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getParentFile();
        File[] configFiles = jarLocation.listFiles(f -> f.isFile() && f.getName().equals("ruuvi-names.properties"));
        if (configFiles == null || configFiles.length == 0) {
            // look for config files in the parent directory if none found in the current directory, this is useful during development when
            // RuuviCollector can be run from maven target directory directly while the config file sits in the project root
            configFiles = jarLocation.getParentFile().listFiles(f -> f.isFile() && f.getName().equals("ruuvi-names.properties"));
        }
        if (configFiles != null && configFiles.length > 0) {
            LOG.debug("Tag names: " + configFiles[0]);
            Properties props = new Properties();
            props.load(new FileInputStream(configFiles[0]));
            Enumeration<?> e = props.propertyNames();
            while (e.hasMoreElements()) {
                String key = StringUtils.trimToEmpty((String) e.nextElement()).toUpperCase();
                String value = StringUtils.trimToEmpty(props.getProperty(key));
                if (key.length() == 12 && value.length() > 0) {
                    TAG_NAMES.put(key, value);
                }
            }
        }
    } catch (URISyntaxException | IOException ex) {
        LOG.warn("Failed to read tag names", ex);
    }
}
 
開發者ID:Scrin,項目名稱:RuuviCollector,代碼行數:27,代碼來源:Config.java

示例3: setClientInfo

import java.util.Properties; //導入方法依賴的package包/類
public synchronized void setClientInfo(java.sql.Connection conn, Properties properties) throws SQLClientInfoException {
    try {
        Enumeration<?> propNames = properties.propertyNames();

        while (propNames.hasMoreElements()) {
            String name = (String) propNames.nextElement();
            String value = properties.getProperty(name);

            setClientInfo(conn, name, value);
        }
    } catch (SQLException sqlEx) {
        SQLClientInfoException clientInfoEx = new SQLClientInfoException();
        clientInfoEx.initCause(sqlEx);

        throw clientInfoEx;
    }
}
 
開發者ID:Jugendhackt,項目名稱:OpenVertretung,代碼行數:18,代碼來源:JDBC4ClientInfoProviderSP.java

示例4: replace

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Replaces all the occurrences of variables in the given source object with their matching
 * values from the properties.
 *
 * @param source the source text containing the variables to substitute, null returns null
 * @param valueProperties the properties with values, may be null
 * @return the result of the replace operation
 * @since 2.6
 */
public static String replace(Object source, Properties valueProperties)
{
    if (valueProperties == null) {
        return source.toString();
    }
    Map valueMap = new HashMap();
    Enumeration propNames = valueProperties.propertyNames();
    while (propNames.hasMoreElements())
    {
        String propName = (String)propNames.nextElement();
        String propValue = valueProperties.getProperty(propName);
        valueMap.put(propName, propValue);
    }
    return StrSubstitutor.replace(source, valueMap);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:StrSubstitutor.java

示例5: vulElementen

import java.util.Properties; //導入方法依賴的package包/類
private static void vulElementen() {
    final Properties elementProperties = leesProperties();
    final Enumeration<?> elementNamen = elementProperties.propertyNames();
    final Map<String, String[]> metVerwijzing = new HashMap<>();
    final Map<String, String[]> zonderVerwijzing = new HashMap<>();

    while (elementNamen.hasMoreElements()) {
        final String elementNaam = (String) elementNamen.nextElement();
        final String[] elementPropertyWaarde = parsePropertyWaarde(elementProperties.getProperty(elementNaam));
        final String groepVerwijzing = elementPropertyWaarde[PROPERTY_GROEP];
        if (isLeeg(groepVerwijzing)) {
            zonderVerwijzing.put(elementNaam, elementPropertyWaarde);
        } else {
            metVerwijzing.put(elementNaam, elementPropertyWaarde);
        }
    }
    vulElementen(zonderVerwijzing);
    vulElementen(metVerwijzing);
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:20,代碼來源:ElementWaarde.java

示例6: packageFromProps

import java.util.Properties; //導入方法依賴的package包/類
/**
 *
 **/
// XXX Either generalize this facility or remove it completely.
protected void packageFromProps (Properties props) throws InvalidArgument
{
  Enumeration propsEnum = props.propertyNames ();
  while (propsEnum.hasMoreElements ())
  {
    String prop = (String)propsEnum.nextElement ();
    if (prop.startsWith ("PkgPrefix."))
    {
      String type = prop.substring (10);
      String pkg = props.getProperty (prop);
      checkPackageNameValid( pkg ) ;
      checkPackageNameValid( type ) ;
      packages.put (type, pkg);
    }
  }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:Arguments.java

示例7: loadParameters

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Helper to load parameters from a .properties file
 */
private Map<String, Object> loadParameters() throws Exception {
    Properties prop = new Properties();
    prop.load(new FileInputStream("src/main/resources/application.properties"));

    Map<String, Object> answer = new HashMap<>();
    Enumeration<?> en = prop.propertyNames();
    while (en.hasMoreElements()) {
        String key = (String) en.nextElement();
        Object value = prop.getProperty(key);
        answer.put(key, value);

    }
    return answer;
}
 
開發者ID:syndesisio,項目名稱:connectors,代碼行數:18,代碼來源:TwitterPingCheck.java

示例8: toMap

import java.util.Properties; //導入方法依賴的package包/類
protected Map<String, String> toMap(Properties properties) {
  Map<String, String> result = Maps.newHashMap();
  Enumeration<?> propertyNames = properties.propertyNames();
  while (propertyNames.hasMoreElements()) {
    String name = (String) propertyNames.nextElement();
    String value = properties.getProperty(name);
    result.put(name, value);
  }
  return result;
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:11,代碼來源:AbstractConfigurationProvider.java

示例9: addProperties

import java.util.Properties; //導入方法依賴的package包/類
public void addProperties(Properties props) {

        if (props == null) {
            return;
        }

        Enumeration keys = props.propertyNames();

        while (keys.hasMoreElements()) {
            String key   = (String) keys.nextElement();
            String value = props.getProperty(key);

            this.stringProps.put(key, value);
        }
    }
 
開發者ID:Julien35,項目名稱:dev-courses,代碼行數:16,代碼來源:HsqlProperties.java

示例10: createCacheClient

import java.util.Properties; //導入方法依賴的package包/類
public static void createCacheClient(Pool poolAttr, String regionName, Properties dsProperties,
    Boolean addControlListener, Properties javaSystemProperties) throws Exception {
  new CacheServerTestUtil().createCache(dsProperties);
  IgnoredException.addIgnoredException("java.net.ConnectException||java.net.SocketException");

  if (javaSystemProperties != null && javaSystemProperties.size() > 0) {
    Enumeration e = javaSystemProperties.propertyNames();

    while (e.hasMoreElements()) {
      String key = (String) e.nextElement();
      System.setProperty(key, javaSystemProperties.getProperty(key));
    }
  }

  PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory();
  pf.init(poolAttr);
  PoolImpl p = (PoolImpl) pf.create("CacheServerTestUtil");
  AttributesFactory factory = new AttributesFactory();
  factory.setScope(Scope.LOCAL);
  factory.setPoolName(p.getName());
  if (addControlListener.booleanValue()) {
    factory.addCacheListener(new ControlListener());
  }
  RegionAttributes attrs = factory.create();
  cache.createRegion(regionName, attrs);
  pool = p;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:28,代碼來源:CacheServerTestUtil.java

示例11: load

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Loads timeouts values.
 *
 * @param stream Stream to load timeouts from.
 * @see org.netbeans.jemmy.Timeouts#load(String)
 * @see org.netbeans.jemmy.Timeouts#load()
 * @exception IOException
 */
public void load(InputStream stream)
        throws IOException {
    Properties props = new Properties();
    props.load(stream);
    Enumeration<?> propNames = props.propertyNames();
    long propValue;
    String propName = null;
    while (propNames.hasMoreElements()) {
        propName = (String) propNames.nextElement();
        propValue = Long.parseLong(props.getProperty(propName));
        setTimeout(propName, propValue);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:Timeouts.java

示例12: createOutputProperties

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Internal method to create the initial set of properties. There
 * are two layers of properties: the default layer and the base layer.
 * The latter contains properties defined in the stylesheet or by
 * the user using this API.
 */
private Properties createOutputProperties(Properties outputProperties) {
    final Properties defaults = new Properties();
    setDefaults(defaults, "xml");

    // Copy propeties set in stylesheet to base
    final Properties base = new Properties(defaults);
    if (outputProperties != null) {
        final Enumeration names = outputProperties.propertyNames();
        while (names.hasMoreElements()) {
            final String name = (String) names.nextElement();
            base.setProperty(name, outputProperties.getProperty(name));
        }
    }
    else {
        base.setProperty(OutputKeys.ENCODING, _translet._encoding);
        if (_translet._method != null)
            base.setProperty(OutputKeys.METHOD, _translet._method);
    }

    // Update defaults based on output method
    final String method = base.getProperty(OutputKeys.METHOD);
    if (method != null) {
        if (method.equals("html")) {
            setDefaults(defaults,"html");
        }
        else if (method.equals("text")) {
            setDefaults(defaults,"text");
        }
    }

    return base;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:39,代碼來源:TransformerImpl.java

示例13: init

import java.util.Properties; //導入方法依賴的package包/類
private void init() {
    // GET APPLETVIEWER USER-SPECIFIC PROPERTIES
    Properties avProps = getAVProps();

    // ADD OTHER RANDOM PROPERTIES
    // XXX 5/18 need to revisit why these are here, is there some
    // standard for what is available?

    // Standard browser properties
    avProps.put("browser", "sun.applet.AppletViewer");
    avProps.put("browser.version", "1.06");
    avProps.put("browser.vendor", "Oracle Corporation");
    avProps.put("http.agent", "Java(tm) 2 SDK, Standard Edition v" + theVersion);

    // Define which packages can be extended by applets
    // XXX 5/19 probably not needed, not checked in AppletSecurity
    avProps.put("package.restrict.definition.java", "true");
    avProps.put("package.restrict.definition.sun", "true");

    // Define which properties can be read by applets.
    // A property named by "key" can be read only when its twin
    // property "key.applet" is true.  The following ten properties
    // are open by default.  Any other property can be explicitly
    // opened up by the browser user by calling appletviewer with
    // -J-Dkey.applet=true
    avProps.put("java.version.applet", "true");
    avProps.put("java.vendor.applet", "true");
    avProps.put("java.vendor.url.applet", "true");
    avProps.put("java.class.version.applet", "true");
    avProps.put("os.name.applet", "true");
    avProps.put("os.version.applet", "true");
    avProps.put("os.arch.applet", "true");
    avProps.put("file.separator.applet", "true");
    avProps.put("path.separator.applet", "true");
    avProps.put("line.separator.applet", "true");

    // Read in the System properties.  If something is going to be
    // over-written, warn about it.
    Properties sysProps = System.getProperties();
    for (Enumeration e = sysProps.propertyNames(); e.hasMoreElements(); ) {
        String key = (String) e.nextElement();
        String val = (String) sysProps.getProperty(key);
        String oldVal;
        if ((oldVal = (String) avProps.setProperty(key, val)) != null)
            System.err.println(lookup("main.warn.prop.overwrite", key,
                                      oldVal, val));
    }

    // INSTALL THE PROPERTY LIST
    System.setProperties(avProps);

    // Create and install the security manager
    if (!noSecurityFlag) {
        System.setSecurityManager(new AppletSecurity());
    } else {
        System.err.println(lookup("main.nosecmgr"));
    }

    // REMIND: Create and install a socket factory!
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:61,代碼來源:Main.java

示例14: activationArgs

import java.util.Properties; //導入方法依賴的package包/類
private String[] activationArgs(ActivationGroupDesc desc) {
    ActivationGroupDesc.CommandEnvironment cmdenv;
    cmdenv = desc.getCommandEnvironment();

    // argv is the literal command to exec
    List<String> argv = new ArrayList<>();

    // Command name/path
    argv.add((cmdenv != null && cmdenv.getCommandPath() != null)
                ? cmdenv.getCommandPath()
                : command[0]);

    // Group-specific command options
    if (cmdenv != null && cmdenv.getCommandOptions() != null) {
        argv.addAll(Arrays.asList(cmdenv.getCommandOptions()));
    }

    // Properties become -D parameters
    Properties props = desc.getPropertyOverrides();
    if (props != null) {
        for (Enumeration<?> p = props.propertyNames();
             p.hasMoreElements();)
        {
            String name = (String) p.nextElement();
            /* Note on quoting: it would be wrong
             * here, since argv will be passed to
             * Runtime.exec, which should not parse
             * arguments or split on whitespace.
             */
            argv.add("-D" + name + "=" + props.getProperty(name));
        }
    }

    /* Finally, rmid-global command options (e.g. -C options)
     * and the classname
     */
    for (int i = 1; i < command.length; i++) {
        argv.add(command[i]);
    }

    String[] realArgv = new String[argv.size()];
    System.arraycopy(argv.toArray(), 0, realArgv, 0, realArgv.length);

    return realArgv;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:46,代碼來源:Activation.java

示例15: processProperties

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Sets the values of Options using the values in <code>properties</code>.
 *
 * @param properties The modifier properties to be processed.
 * @throws ParseException if there are any problems encountered
 *                        while processing the properties.
 */
protected void processProperties(Properties properties) throws ParseException
{
    if (properties == null)
    {
        return;
    }

    for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements();)
    {
        String option = e.nextElement().toString();

        Option opt = options.getOption(option);
        if (opt == null)
        {
            throw new UnrecognizedOptionException("Default option wasn't defined", option);
        }

        // if the option is part of a group, check if another option of the group has been selected
        OptionGroup group = options.getOptionGroup(opt);
        boolean selected = group != null && group.getSelected() != null;

        if (!cmd.hasOption(option) && !selected)
        {
            // get the modifier from the properties instance
            String value = properties.getProperty(option);

            if (opt.hasArg())
            {
                if (opt.getValues() == null || opt.getValues().length == 0)
                {
                    try
                    {
                        opt.addValueForProcessing(value);
                    }
                    catch (RuntimeException exp) //NOPMD
                    {
                        // if we cannot add the modifier don't worry about it
                    }
                }
            }
            else if (!("yes".equalsIgnoreCase(value)
                    || "true".equalsIgnoreCase(value)
                    || "1".equalsIgnoreCase(value)))
            {
                // if the modifier is not yes, true or 1 then don't add the
                // option to the CommandLine
                continue;
            }

            cmd.addOption(opt);
            updateRequiredOptions(opt);
        }
    }
}
 
開發者ID:LasmGratel,項目名稱:FoodCraft-Reloaded,代碼行數:62,代碼來源:Parser.java


注:本文中的java.util.Properties.propertyNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。