I have a config File "Replace_IP_List.cfg" as below
10.19.120.39=[fec0:1111:2222:3333:4444]
[fec0:2222:2222:3333:4444] = 10.18.215.151
I am reading cfg file to get keys and values, since the key has ':' , i am not able to get full string,
Properties prop = new Properties();
InputStream is = new FileInputStream("Replace_IP_List.cfg");
prop.load(is);
Enumeration<?> e = prop.propertyNames();
while (e.hasMoreElements())
{
String key = (String) e.nextElement();
String value = prop.getProperty(key);
System.out.println("Key : " + key + ", Value : " + value);
str=str.replace(key, value);
output:
Key : 10.19.120.39, Value : [fec0:1111:2222:3333:4444]
Key : [fec0, Value : 2222:2222:3333:4444] = 10.18.215.151
the cfg file is generated runtime(or it is provided by others) i donot need to edit the cfg file or escape as :
can anyone suggest me Inside program how i can escape : and consider only = while reading the file. Expected output as below,
Key : 10.19.120.39, Value : [fec0:1111:2222:3333:4444]
Key : [fec0:2222:2222:3333:4444], Value : 10.18.215.151