List of utility methods to do Properties Load from File
Map | loadPropertiesFile(String propertiesFileName) load Properties File Properties properties = new Properties(); properties.load(new FileInputStream(propertiesFileName)); return (Map) properties; |
Properties | loadPropertiesFile(String propFile) Loads properties from file. Properties fProps = new Properties(); try (InputStream is = new FileInputStream(new File(propFile))) { fProps.load(is); return fProps; |
Properties | loadPropertiesFile(String propFilePath) load Properties File try (InputStream input = new FileInputStream(propFilePath)) { return loadPropertiesStream(input); |
Properties | loadPropertiesFromClasspath(final String filename) Loads Properties using current thread's classloader. Properties properties = new Properties(); properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)); return properties; |
Properties | loadPropertiesFromClasspath(Class loadResourceClass, String classpath) load Properties From Classpath Properties aprops = new Properties(); InputStream ios = loadResourceClass.getResource(classpath).openStream(); aprops.load(ios); return aprops; |
Properties | loadPropertiesFromClasspath(String pfname) load Properties From Classpath Properties p = new Properties(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); InputStream is = cl.getResourceAsStream(pfname); if (is == null) throw new RuntimeException("Could not find " + pfname + " in CLASSPATH"); try { p.load(is); } catch (Exception e) { ... |
Properties | loadPropertiesFromFile(Class> clazz, String filePath) load by clazz InputStream inputStream = clazz.getClassLoader().getResourceAsStream(filePath);
return loadPropertiesFromInputStream(inputStream);
|
Map | loadPropertiesFromFile(JarFile jar) load Properties From File Map<String, String> result = new HashMap<String, String>(); Properties props = new Properties(); JarEntry entry = jar.getJarEntry("conf/plugin.properties"); if (entry != null) { InputStream in = jar.getInputStream(entry); props.load(in); Enumeration<?> en = props.propertyNames(); while (en.hasMoreElements()) { ... |
InputStream | loadPropertiesFromFile(String configFile) load Properties From File final InputStream input = new FileInputStream(configFile); final Properties prop = new Properties(); prop.load(input); server = prop.getProperty("ras.server", DEFAULT_SERVER); database = prop.getProperty("ras.database", DEFAULT_BASE); port = prop.getProperty("ras.port", DEFAULT_PORT); username = prop.getProperty("ras.username", DEFAULT_USER); password = prop.getProperty("ras.password", DEFAULT_PASSWD); ... |
Properties | loadPropertiesFromFile(String filePath) load Properties From File File configFile = new File(filePath); if (!configFile.exists()) { throw new FileNotFoundException("Configuration file \"" + filePath + "\" could not be found"); System.out.println("Configuration file located in " + filePath); InputStream inputStream = new FileInputStream(filePath); return loadProperties(inputStream); |