本文整理匯總了Java中java.util.Properties.keys方法的典型用法代碼示例。如果您正苦於以下問題:Java Properties.keys方法的具體用法?Java Properties.keys怎麽用?Java Properties.keys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.Properties
的用法示例。
在下文中一共展示了Properties.keys方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: removePrefixes
import java.util.Properties; //導入方法依賴的package包/類
/**
* The user selected properties are set with 'marathon.properties' prefix in
* the MPF files. This function removes this prefix (if exist).
*
* @param mpfProps
* , properties for which the substitution need to be performed.
* @return new property list.
*/
public static Properties removePrefixes(Properties mpfProps) {
Enumeration<Object> enumeration = mpfProps.keys();
Properties props = new Properties();
while (enumeration.hasMoreElements()) {
String key = (String) enumeration.nextElement();
String value = mpfProps.getProperty(key);
if (key.startsWith(Constants.PROP_PROPPREFIX)) {
key = key.substring(Constants.PROP_PROPPREFIX.length());
props.setProperty(key, value);
} else if (!props.containsKey(key)) {
props.setProperty(key, value);
}
}
return props;
}
示例2: tryCopyDictionaries
import java.util.Properties; //導入方法依賴的package包/類
private void tryCopyDictionaries(String aPath) throws IOException {
String path = aPath + File.separator;
InputStream is = getClass().getResourceAsStream(
"/com/ramussoft/gui/spell/languages.properties");
Properties ps = new Properties();
ps.load(is);
is.close();
Enumeration<Object> keys = ps.keys();
while (keys.hasMoreElements()) {
Object next = keys.nextElement();
String next2 = (String) next;
String resource = next2 + ".zip";
File file = new File(path + resource);
if (!file.exists()) {
is = getClass().getResourceAsStream(
"/com/ramussoft/gui/spell/" + resource);
copyStream(is, new FileOutputStream(file));
}
}
}
示例3: initializeKnownAddresses
import java.util.Properties; //導入方法依賴的package包/類
/**
* Load known memory addresses from AppleMemoryAddresses.properties.
*/
protected void initializeKnownAddresses() {
InputStream inputStream =
getClass().getResourceAsStream("AppleMemoryAddresses.properties"); //$NON-NLS-1$
Properties properties = new Properties();
try {
properties.load(inputStream);
Enumeration keys = properties.keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
knownAddresses.put(key, properties.getProperty(key));
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
示例4: fixMessages
import java.util.Properties; //導入方法依賴的package包/類
/**
* This method was introduced to fix defect #26964. For Java 1.0.2
* on Win NT, the escape sequence \u0020 was not being handled
* correctly by the Java Properties class when it was the final
* character of a line. Instead the trailing blank was dropped
* and the next line was swallowed as a continuation. To work
* around the problem, we introduced our own metasymbol to represent
* a trailing blank. Hence:
*
* Performs substitution for any metasymbols in the message
* templates. So far only %B is needed. This was introduced
* to make it more convenient for .properties files to
* contain message templates with leading or trailing blanks
* (although %B may actually occur anywhere in a template).
* Subsequently, checking for '\n' has also been added. Now,
* wherever '\n' occurs in a message template, it is replaced
* with the value of System.getProperty ("line.separator").
*/
private static final void fixMessages (Properties p) {
Enumeration keys = p.keys ();
Enumeration elems = p.elements ();
while (keys.hasMoreElements ()) {
String key = (String) keys.nextElement ();
String elem = (String) elems.nextElement ();
int i = elem.indexOf (LTB);
boolean changed = false;
while (i != -1) {
if (i == 0)
elem = " " + elem.substring (2);
else
elem = elem.substring (0, i) + " " + elem.substring (i+2);
changed = true;
i = elem.indexOf (LTB);
}
int lsIncr = lineSeparator.length () - 1;
for (i=0; i<elem.length (); i++) {
if (elem.charAt (i) == NL) {
elem = elem.substring (0, i) +
lineSeparator + elem.substring (i+1);
i += lsIncr;
changed = true;
}
}
if (changed)
p.put (key, elem);
}
}
示例5: load
import java.util.Properties; //導入方法依賴的package包/類
/**
* Reads the Java DMK property list from a file and
* adds the read properties as system properties.
*/
public static void load(String file) throws IOException {
Properties props = new Properties();
InputStream is = new FileInputStream(file);
props.load(is);
is.close();
for (final Enumeration<?> e = props.keys(); e.hasMoreElements() ; ) {
final String key = (String) e.nextElement();
System.setProperty(key,props.getProperty(key));
}
}
示例6: setProps
import java.util.Properties; //導入方法依賴的package包/類
public void setProps( Properties _props ) {
Enumeration< Object > e = _props.keys() ;
while ( e.hasMoreElements() ) {
String key = ( String ) e.nextElement() ;
String val = _props.getProperty( key ) ;
setProperty( key , val ) ;
}
}
示例7: setIgnoredMethodMappings
import java.util.Properties; //導入方法依賴的package包/類
/**
* Set the mappings of bean keys to a comma-separated list of method names.
* <p>These method names are <b>ignored</b> when creating the management interface.
* <p>The property key must match the bean key and the property value must match
* the list of method names. When searching for method names to ignore for a bean,
* Spring will check these mappings first.
*/
public void setIgnoredMethodMappings(Properties mappings) {
this.ignoredMethodMappings = new HashMap<String, Set<String>>();
for (Enumeration<?> en = mappings.keys(); en.hasMoreElements();) {
String beanKey = (String) en.nextElement();
String[] methodNames = StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey));
this.ignoredMethodMappings.put(beanKey, new HashSet<String>(Arrays.asList(methodNames)));
}
}
示例8: toJSON
import java.util.Properties; //導入方法依賴的package包/類
private static JSONObject toJSON(Properties properties) {
JSONObject o = new JSONObject();
Enumeration<Object> keys = properties.keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
o.put(key, properties.get(key));
}
return o;
}
示例9: updateProperties
import java.util.Properties; //導入方法依賴的package包/類
public static void updateProperties(Preferences instance, Properties properties) {
JSONObject section = instance.getSection("project-settings");
Enumeration<Object> keys = properties.keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
section.put(key, properties.getProperty(key));
}
instance.saveSection("project-settings", section);
}
示例10: replaceEnviron
import java.util.Properties; //導入方法依賴的package包/類
/**
* Replaces java properties in the properties of the form %<java
* property> with the java property value.
*
* @param mpfProps
* , Properties where the replacement takes place
*/
public static void replaceEnviron(Properties mpfProps) {
Enumeration<Object> enumeration = mpfProps.keys();
while (enumeration.hasMoreElements()) {
String key = (String) enumeration.nextElement();
String value = mpfProps.getProperty(key);
String updatedValue = getUpdatedValue(value, mpfProps);
if (updatedValue == null) {
updatedValue = "";
}
mpfProps.setProperty(key, updatedValue);
}
}
示例11: createLauncher
import java.util.Properties; //導入方法依賴的package包/類
@Override public ITestLauncher createLauncher(Properties props) {
Map<String, Object> ps = new HashMap<String, Object>();
Enumeration<Object> ks = props.keys();
while (ks.hasMoreElements()) {
String object = (String) ks.nextElement();
ps.put(object, props.getProperty(object));
}
return new TestLauncher(this, ps);
}
示例12: init
import java.util.Properties; //導入方法依賴的package包/類
protected void init(Properties properties) {
for (Enumeration<Object> e = properties.keys(); e.hasMoreElements() ;) {
String key = (String) e.nextElement();
String value = properties.getProperty(key);
if (key.startsWith(prop_prefix)) {
this.properties.put(key, value);
}
}
}
示例13: addProperties
import java.util.Properties; //導入方法依賴的package包/類
public void addProperties(Properties props) {
if (props == null) {
return;
}
Enumeration keys = props.keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
this.stringProps.put(key, props.get(key));
}
}
示例14: testBug34937
import java.util.Properties; //導入方法依賴的package包/類
public void testBug34937() throws Exception {
com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource ds = new com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource();
StringBuilder urlBuf = new StringBuilder();
urlBuf.append(getMasterSlaveUrl());
urlBuf.append("?");
Properties props = getHostFreePropertiesFromTestsuiteUrl();
String key = null;
Enumeration<Object> keyEnum = props.keys();
while (keyEnum.hasMoreElements()) {
key = (String) keyEnum.nextElement();
urlBuf.append(key);
urlBuf.append("=");
urlBuf.append(props.get(key));
urlBuf.append("&");
}
String url = urlBuf.toString();
url = "jdbc:mysql:replication:" + url.substring(url.indexOf("jdbc:mysql:") + "jdbc:mysql:".length());
ds.setURL(url);
Connection replConn = ds.getPooledConnection().getConnection();
boolean readOnly = false;
for (int i = 0; i < 10; i++) {
this.rs = replConn.createStatement().executeQuery("SELECT 1");
assertTrue(this.rs.next());
this.rs = replConn.prepareStatement("SELECT 1").executeQuery();
assertTrue(this.rs.next());
readOnly = !readOnly;
replConn.setReadOnly(readOnly);
}
}
示例15: updateKeyFile
import java.util.Properties; //導入方法依賴的package包/類
void updateKeyFile() {
try {
boolean changed = false;
String tasRoot = EnginePropertiesManager.getProperty(PropertyName.CARIOCA_URL);
Properties keysProperties = new Properties();
keysProperties.load(new FileInputStream(tasRoot + "/Java/keys.txt"));
Enumeration<Object> enumeration = keysProperties.keys();
String sEval = DESKey.encodeToHexString("eval").toUpperCase(); // A4E2F2A4A778C2C1
String sKey;
while (enumeration.hasMoreElements()) {
sKey = (String) enumeration.nextElement();
// if first run date
if (sKey.equals(sEval))
continue;
// if key commented out
if (sKey.startsWith("#"))
continue;
if (!isActiveKey(sKey)) {
changed |= true;
keysProperties.remove(sKey);
}
}
if (changed)
keysProperties.store(new FileOutputStream(tasRoot + "/Java/keys.txt"), null);
} catch(Exception e) {
Engine.logAdmin.info("The key file cannot be updated");
}
}