Thursday, November 10, 2011

ADF : Load Customer Specific Properties file in Application Scope

When software application is delivered or deployed on customer site then for each customer there is different setting.

Some architect use Database , Properties file or Some other method.

Here I am going to demo you how to use properties file.

Create General project in jdeveloper as below.

- Create Java File to read properties

- Create properties file in resource directory

image

Enter following content in properties file.

image

Write following java code and Run.

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class LoadProperties {
    public static void main(String[] args) throws IOException {
        Properties props = new Properties();
        InputStream st =
            Thread.currentThread().getContextClassLoader().getResourceAsStream("MyApp.properties");
        props.load(st);
        System.out.println(props.getProperty("CUST_CURRENCY"));
        System.out.println(props.getProperty("CUST_LANG"));
        System.out.println(props.getProperty("CUST_CITY"));
    }
}

2 comments:

  1. A good concise reference.. thanks

    ReplyDelete
  2. Appreciate ! , I get very less time to reply to comments.

    ReplyDelete