简体   繁体   中英

How to read data from config.properties file line by line in JAVA on the server side not on the client side

i have a config.prop file where i have set key value pairs(key=name,value=url's)

this is a sample value. I have 20-30 key-value pair like this dividing into 4 different sets. Like user 1 can see first 5 URL's which are coming in the config. prop file and goes on for user-2, user-3, user-4 which see's the next 5 URL's

FILE_TT="";

My application is running dynamic and wants to read the urls line by line from the config.properties file so that when the next user comes it shows only that url's which are specified for that user. any idea? or another suggestion where I can read the key-value pair. I don't want any hardcoded method.

You can use java.util.Properties which is a hashtable implementation

File f=new File("Complete path of your config file");
            InputStream i=new FileInputStream(f);
            Properties p =new Properties();
            p.load(i);
         String value= p.getProperty("key"); //you can search for a property

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM