Java Utililty Methods Properties Load from File

List of utility methods to do Properties Load from File

Description

The list of methods to do Properties Load from File are organized into topic(s).

Method

PropertiesloadProperties(final Class clasz, final String propertiesFilename)
Loads a properties file.
final Properties props = new Properties();
final InputStream inStream = clasz.getResourceAsStream(propertiesFilename);
if (inStream == null) {
    throw new IOException("Resource '" + propertiesFilename + "' not found!");
try {
    props.load(inStream);
} finally {
...
PropertiesloadProperties(final File f)
load Properties
Properties properties = new Properties();
properties.load(new FileInputStream(f));
return properties;
PropertiesloadProperties(final File propertiesFile)
Reads the properties from the specified file, and loads them into a Properties object.
final Properties properties = new Properties();
final FileInputStream fis = new FileInputStream(propertiesFile);
try {
    properties.load(fis);
} finally {
    fis.close();
return properties;
...
PropertiesloadProperties(final String file)
load Properties
final Properties props = new Properties();
FileReader fr = null;
try {
    fr = new FileReader(file);
    props.load(fr);
    return props;
} catch (final FileNotFoundException fe) {
    System.out.println("File not found" + file);
...
PropertiesloadProperties(final String fileName)
load Properties
return loadProperties("", fileName);
PropertiesloadProperties(final ZipFile file, final ZipEntry ze)
load Properties
final Properties p = new Properties();
p.load(file.getInputStream(ze));
return p;
PropertiesloadProperties(JarFile enclosedJarFile, String jarEntryPath)
Loads the properties file residing inside a jar.
JarEntry jarEntry = enclosedJarFile.getJarEntry(jarEntryPath);
InputStream inputStream = enclosedJarFile.getInputStream(jarEntry);
Properties properties = new Properties();
properties.load(inputStream);
return properties;
voidloadProperties(Map map, File file, String encoding)
load Properties
BufferedReader br = null;
try {
    br = new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
    String key = null;
    String line;
    int cpt = 1;
    while ((line = br.readLine()) != null) {
        if (line.length() != 0) {
...
MaploadProperties(ProcessingEnvironment env, String fileName)
Attempts to load fileName and return its properties.
Map<String, String> properties = new LinkedHashMap<String, String>();
File file = null;
for (Location location : new Location[] { StandardLocation.SOURCE_OUTPUT, StandardLocation.CLASS_OUTPUT }) {
    file = resolveBindgenPropertiesIfExists(location, env, fileName);
    if (file != null) {
        break;
if (file != null) {
    Properties p = new Properties();
    try {
        p.load(new FileInputStream(file));
    } catch (Exception e) {
        e.printStackTrace();
    for (Map.Entry<Object, Object> entry : p.entrySet()) {
        properties.put((String) entry.getKey(), (String) entry.getValue());
return properties;
PropertiesloadProperties(Properties properties, File file)
load Properties
try (InputStream propertiesStream = new FileInputStream(file)) {
    return loadProperties(properties, propertiesStream);