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


Java Properties.load方法代碼示例

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


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

示例1: init

import java.util.Properties; //導入方法依賴的package包/類
public boolean init() {
 	props = new Properties();
 	
 	if (fileName == null)
 		return false;
     
 	try {
         InputStream inStream = new FileInputStream(fileName);
         props.load(inStream);
         /*Iterator iter = props.keySet().iterator();
         logger.debug("Properties:");
         while (iter.hasNext()) {
             String key = (String)iter.next();
             logger.debug(key + " -> " + props.get(key));
         }*/
         return true;
     }
     catch (IOException e) {
ConvertigoPlugin.logException(e, "Unexpected exception");
         throw new RuntimeException("Couldn't read properties");
     }
 }
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:23,代碼來源:ConfigManager.java

示例2: mergeProperties

import java.util.Properties; //導入方法依賴的package包/類
private void mergeProperties(InputStream is,
                             File confFile,
                             Collection<String> configMods,
                             Properties prop)
                                     throws FloodlightModuleException {
    try {
        Properties fprop = new Properties();
        if (is != null) {
            fprop.load(is);
        } else {
            try (FileInputStream fis = new FileInputStream(confFile)) {
                fprop.load(fis);
            }
        }
        String moduleList = fprop.getProperty(FLOODLIGHT_MODULES_KEY);
        if (moduleList != null) {
            moduleList = moduleList.replaceAll("\\s", "");
            configMods.addAll(Arrays.asList(moduleList.split(",")));
        }
        fprop.remove(FLOODLIGHT_MODULES_KEY);

        prop.putAll(fprop);
    } catch (IOException e) {
        throw new FloodlightModuleException(e);
    }
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:27,代碼來源:FloodlightModuleLoader.java

示例3: calculateConfigs

import java.util.Properties; //導入方法依賴的package包/類
@NonNull
private Map<String,Configuration> calculateConfigs() {
    final Map<String,Configuration> cfgs = new HashMap<>();
    if (configDir != null) {
        for (FileObject kid : configDir.getChildren()) {
            if (!kid.hasExt("properties")) {    //NOI18N
                continue;
            }
            try {
                try (InputStream is = kid.getInputStream()) {
                    final Properties props = new Properties();
                    props.load(is);
                    final String name = kid.getName();
                    final String label = props.getProperty("$label"); // NOI18N
                    cfgs.put(name, new Configuration(name, label != null ? label : name));
                }
            } catch (IOException x) {
                LOGGER.log(Level.INFO, null, x);
            }
        }
    }
    configs = cfgs;
    LOGGER.log(Level.FINEST, "Calculated configurations: {0}", cfgs);
    return cfgs;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:ProjectConfigurations.java

示例4: propertiesFromFile

import java.util.Properties; //導入方法依賴的package包/類
private static Properties propertiesFromFile(String fname)
    throws IOException {
    FileInputStream fin = new FileInputStream(fname);
    try {
        Properties p = new Properties();
        p.load(fin);
        return p;
    } finally {
        fin.close();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:MBeanServerFileAccessController.java

示例5: loadRelocation

import java.util.Properties; //導入方法依賴的package包/類
@NonNull
private static Properties loadRelocation(
        @NonNull final File cacheRoot) {
    final Properties result = new Properties();
    final  File relocationFile = new File (cacheRoot, RELOCATION_FILE);
    if (relocationFile.canRead()) {
        try {
            final FileInputStream in = new FileInputStream(relocationFile);
            try {
                result.load(in);
           } finally {
                in.close();
           }
        } catch (IOException ioe) {
            Exceptions.printStackTrace(ioe);
        }
    }
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:TaskCache.java

示例6: loadProperties

import java.util.Properties; //導入方法依賴的package包/類
private Properties loadProperties(String location) {
    Properties prop = new Properties();
    if (new File(location).exists()) {
        try (FileInputStream inputStream = new FileInputStream(location)) {
            prop.load(inputStream);
        } catch (IOException ex) {
            Logger.getLogger(SeleniumServer.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    return prop;
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:12,代碼來源:SeleniumServer.java

示例7: setOsNameAndVersion

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Sets the OS name and version from environment information.
 */
protected void setOsNameAndVersion(){
    super.setOsNameAndVersion();

    if (osName.equals("SunOS")) {
        //don't care os name on Solaris
        osName = null;
    } else if (osName.equals("Linux")) {
        try {
            File f;
            if ((f = new File("/etc/fedora-release")).canRead()) {
                osName = "Fedora";
                osVersion = getVersionString(f);
            } else if ((f = new File("/etc/redhat-release")).canRead()) {
                osName = "RedHat";
                osVersion = getVersionString(f);
            } else if ((f = new File("/etc/turbolinux-release")).canRead()) {
                osName = "Turbo";
                osVersion = getVersionString(f);
            } else if ((f = new File("/etc/SuSE-release")).canRead()) {
                osName = "SuSE";
                osVersion = getVersionString(f);
            } else if ((f = new File("/etc/lsb-release")).canRead()) {
                /* Ubuntu and (perhaps others) use only lsb-release.
                 * Syntax and encoding is compatible with java properties.
                 * For Ubuntu the ID is "Ubuntu".
                 */
                Properties props = new Properties();
                props.load(new FileInputStream(f));
                osName = props.getProperty("DISTRIB_ID");
                osVersion =  props.getProperty("DISTRIB_RELEASE");
            }
        } catch (Exception e) {
        }
    }
    return;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:40,代碼來源:MFontConfiguration.java

示例8: parseProperties

import java.util.Properties; //導入方法依賴的package包/類
public static Properties parseProperties(String propertyString) {
	Properties properties = new Properties();
	try {
		Reader propertyReader = new StringReader(propertyString.replaceAll(";", "\n"));
		properties.load(propertyReader);
	} catch (IOException e) {
		// Can't happen with StringReader
	}
	return properties;
}
 
開發者ID:ncredinburgh,項目名稱:secure-tomcat-datasourcefactory,代碼行數:11,代碼來源:PropertyParser.java

示例9: getSecondaryServicePrincipalClientID

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Retrieve the secondary service principal client ID.
 * @param envSecondaryServicePrincipal an Azure Container Registry
 * @return a service principal client ID
 * @throws Exception exception
 */
public static String getSecondaryServicePrincipalClientID(String envSecondaryServicePrincipal) throws Exception {
    Properties authSettings = new Properties();
    FileInputStream credentialsFileStream = new FileInputStream(new File(envSecondaryServicePrincipal));
    authSettings.load(credentialsFileStream);
    credentialsFileStream.close();

    return authSettings.getProperty("client");
}
 
開發者ID:Azure-Samples,項目名稱:app-service-java-manage-functions,代碼行數:15,代碼來源:Utils.java

示例10: configLog4j

import java.util.Properties; //導入方法依賴的package包/類
private static void configLog4j() {
	InputStream inStreamLog4j = DiameterServer.class.getClassLoader().getResourceAsStream("log4j.properties");
	Properties propertiesLog4j = new Properties();
	try {
		propertiesLog4j.load(inStreamLog4j);
		PropertyConfigurator.configure(propertiesLog4j);
	} catch (Exception e) {
		e.printStackTrace();
	}

	log.debug("log4j configured");

}
 
開發者ID:P1sec,項目名稱:SigFW,代碼行數:14,代碼來源:DiameterServer.java

示例11: getVersion

import java.util.Properties; //導入方法依賴的package包/類
public String[] getVersion() throws Exception {
    URL url = getClass().getResource("/version.txt");
    if (url == null) {
        return new String[] {"No version.txt file found in the classpath. Is examples.jar in the classpath?"};
    }
    Properties properties = new Properties();
    properties.load(url.openStream());
    return new String[] {
            properties.getProperty("Application-name") + " version \"" + properties.getProperty("Version") + "\"",
            "Built: " + properties.getProperty("Buildtime"),
    };
}
 
開發者ID:remkop,項目名稱:picocli,代碼行數:13,代碼來源:VersionProviderDemo1.java

示例12: readProperties

import java.util.Properties; //導入方法依賴的package包/類
public AgroalPropertiesReader readProperties(File file) throws IOException {
    try ( InputStream inputStream = new FileInputStream( file ) ) {
        Properties properties = new Properties();
        properties.load( inputStream );
        return readProperties( properties );
    }
}
 
開發者ID:agroal,項目名稱:agroal,代碼行數:8,代碼來源:AgroalPropertiesReader.java

示例13: loadProperties

import java.util.Properties; //導入方法依賴的package包/類
private static void loadProperties(File propertiesFile, Properties properties) throws IOException {
    InputStream inStream = new FileInputStream(propertiesFile);
    try {
        properties.load(inStream);
    } finally {
        inStream.close();
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:9,代碼來源:WrapperExecutor.java

示例14: getSchemaExport

import java.util.Properties; //導入方法依賴的package包/類
private SchemaExport getSchemaExport(Configuration cfg) throws HibernateException, IOException {
	Properties properties = new Properties();
	properties.putAll( cfg.getProperties() );
	if (propertiesFile == null) {
		properties.putAll( getProject().getProperties() );
	}
	else {
		properties.load( new FileInputStream(propertiesFile) );
	}
	cfg.setProperties(properties);
	return new SchemaExport(cfg)
			.setHaltOnError(haltOnError)
			.setOutputFile( outputFile.getPath() )
			.setDelimiter(delimiter);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:16,代碼來源:SchemaExportTask.java

示例15: ConfigItem

import java.util.Properties; //導入方法依賴的package包/類
/**
 * 取默認的配置文件
 */
ConfigItem(String file) {
	try (InputStream is = ConfigUtil.class.getResourceAsStream(file)) {
		Properties p = new Properties();
		p.load(is);
		this.pro = p;
	} catch (IOException e) {
		throw new ZhhrException("加載配置信息出錯:" + e.getMessage());
	}
}
 
開發者ID:wooui,項目名稱:springboot-training,代碼行數:13,代碼來源:ConfigItem.java


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