Java Properties Load from File loadProperties(final String file)

Here you can find the source of loadProperties(final String file)

Description

load Properties

License

Apache License

Declaration

public static Properties loadProperties(final String file) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import java.util.Properties;

public class Main {
    public static Properties loadProperties(final String file) {
        final Properties props = new Properties();
        FileReader fr = null;//from ww  w.  jav a  2 s  .  co m
        try {
            fr = new FileReader(file);
            props.load(fr);
            return props;
        } catch (final FileNotFoundException fe) {
            System.out.println("File not found" + file);
            return null;
        } catch (final Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            if (fr != null) {
                try {
                    fr.close();
                } catch (final IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

Related

  1. loadProperties(File propertyFile)
  2. loadProperties(File propertyFile, Properties properties)
  3. loadProperties(final Class clasz, final String propertiesFilename)
  4. loadProperties(final File f)
  5. loadProperties(final File propertiesFile)
  6. loadProperties(final String fileName)
  7. loadProperties(final ZipFile file, final ZipEntry ze)
  8. loadProperties(JarFile enclosedJarFile, String jarEntryPath)
  9. loadProperties(Map map, File file, String encoding)