java - Load properties selectively from properties file based on key value -



java - Load properties selectively from properties file based on key value -

i have property file has values

xxx.key1 = value1 xxx.key2 = value2 yyy.key3 = value3 yyy.key4 = value4

'xxx' , 'yyy' can considered 2 different namespaces. how load property file can load either property of 'xxx' or 'yyy'?

just read each line of file , pull values match namespace.

scanner scan = new scanner(new file("yourfilepath")); map<string,string> map = new hashmap<string, string>(); string value = ""; while(scan.hasnext()) { value = scan.nextline(); if(value.indexof("xxx") != -1) { map.put(value.split(" = ")[0], value.split(" = ")[1]); } } //now map has key value pairs

if properties this

xxx.key1=value in split("=") (no spaces)

java properties namespaces

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -