load Properties - Java java.util

Java examples for java.util:Properties File

Description

load Properties

Demo Code


//package com.java2s;
import java.io.*;
import java.util.*;

public class Main {
    public static void loadProperties(Properties properties, Class clazz,
            String propDir, String name) {
        // load system defaults
        try {/*from w  w w .  j ava2s  .com*/
            properties.load(clazz.getResourceAsStream(name));
        } catch (IOException ioe) {
            System.err.println("Could not load aid property file: " + name);
            System.err.println(ioe);
        }

        // load user defaults
        try {
            if ((propDir != null) && !propDir.equals(".")
                    && !propDir.equals("")) {
                name = propDir + File.separator + name;
            }
            properties.load(new FileInputStream(name));
            //            System.out.println("Loaded user property file: "+name);
        } catch (IOException ioe) {
        }
    }
}

Related Tutorials