[英]unable to parse .conf file using java
<TF_INFO_START>
<TF_HOST>`TF_IN`
<TF_ID>`3219`
<TF_INFO_END>
<SF_INFO>
<SF_NAME>`JOHN`<IP>`10.110.12.12`<SF_PORT>`9101`
<END_SF_INFO>
<COMPONENT_START_TAG>
<COMPONENT_NAME>`AISMOD`<PATH>`AISPATH`<TYPE>`U`<M>`main`
<COMPONENT_END_TAG>
I want to parse the above test.conf file and display each parameter in the log file.I have tried parsing it like 我想解析上面的test.conf文件并在日志文件中显示每个参数。
Properties configFile = new Properties();
configFile.load(new FileInputStream("C:/Users/JOHN/Desktop/test.conf"));
String foo = configFile.getProperty("TF_HOST");
I couldn't get value of TF_HOST and other parameters.I get null result.. 我无法获取TF_HOST和其他参数的值。结果为空。
Can anyone help me in parsing the above file content 谁能帮我解析以上文件内容
Write your conf file as key=value then using ResourceBundle you can easily read the file. 将conf文件写为key = value,然后使用ResourceBundle可以轻松读取文件。 Like
喜欢
ResourceBundle rb = ResourceBundle.getundle("com.demo.conf");//path for conf file in my case it is in com.demo package
String value = rb.getString(key);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.