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

PropertiesloadFixture(String fixtureId)
Return Properties loaded from a fixture configuration file, or null if not found.
File fixtureFile = getFixtureFile(getFixtureDirectory(), fixtureId);
if (fixtureFile.exists()) {
    return loadProperties(fixtureFile);
} else {
    printSkipNotice(fixtureId, fixtureFile);
    return null;
FileloadGradleResource(String fileName)
This can load a gradle resource, such as a .properties file.
File junitFile = new File(fileName);
if (junitFile.exists()) {
    LOGGER.info("The file '" + junitFile.getAbsolutePath() + "' exists.");
} else {
    LOGGER.info("Problem loading Gradle resource: " + junitFile.getAbsolutePath());
return junitFile;
StringloadHeader(String fileName)
Read the header part of a properties file into a String.
FileReader fr = null;
BufferedReader br = null;
try {
    fr = new FileReader(fileName);
    br = new BufferedReader(fr);
    String header = br.readLine();
    if (header != null && header.indexOf('#') == 0) {
        header = header.substring(1);
...
voidloadIncludes(String propertyName, boolean mandatory, File file, Properties configProps)
load Includes
String includes = configProps.getProperty(propertyName);
if (includes != null) {
    StringTokenizer st = new StringTokenizer(includes, "\" ", true);
    if (st.countTokens() > 0) {
        String location;
        do {
            location = nextLocation(st);
            if (location != null) {
...
StringloadInputAsString(InputStream is)
Something really straight forward to read the content of the file.
StringBuilder sb = new StringBuilder();
try {
    BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); 
    String newline = System.getProperty("line.separator"); 
    String line = null;
    while ((line = reader.readLine()) != null) {
        sb.append(line + newline);
} catch (IOException e) {
    e.printStackTrace();
} finally {
    try {
        is.close();
    } catch (IOException e) {
        e.printStackTrace();
return sb.toString();
PropertiesloadInstallProps()
load Install Props
try {
    Properties prop = new Properties();
    prop.load(new FileInputStream("caTissueInstall.properties"));
    return prop;
} catch (Exception e) {
    throw new RuntimeException("Error loading install properties file", e);
PropertiesloadJZ(File file)
load JZ
Properties props = new Properties();
if (file.exists()) {
    try {
        FileReader reader = new FileReader(file);
        char[] buf = new char[1024];
        StringBuffer buffer = new StringBuffer();
        int read = 0;
        boolean isStarted = false;
...
SetloadKeys(String propertiesFileName, InputStream in)
load Keys
Set<String> keys = new HashSet<String>();
Properties prop = new Properties();
if (in == null)
    throw new IOException("unable to get resource file " + propertiesFileName);
prop.load(in);
in.close();
for (Object key : prop.keySet()) {
    keys.add((String) key);
...
voidloadLibrary(String libFileName)
Attempts to load the given library from all paths in java.libary.path.
boolean found = false;
String javaLibPath = System.getProperty("java.library.path");
for (String path : javaLibPath.split(":")) {
    File libFile = new File(path + File.separator + libFileName);
    if (libFile.exists()) {
        System.load(libFile.getPath());
        found = true;
        break;
...
voidloadLibrarySmart(String libraryName)
load Library Smart
if (loadLibrary(libraryName))
    return;
String classPath = System.getProperty("java.class.path");
String stuff[] = classPath.split(":");
for (String s : stuff) {
    File f = new File(s);
    if (!f.isDirectory())
        continue;
...