nat*_*j07 2 java properties sections
我有一个 Java 属性文件,其中有许多不同的属性用于不同的事情:
ui.datasource.st.name=MyTest
ui.datasource.st.port=111
ui.datasource.st.ip=1.1.1.1
ui.outputtype.snapshot=Snapshot
ui.outputtype.spreadsheet=Spreadsheet - xls
Run Code Online (Sandbox Code Playgroud)
该文件比这个大得多。
我想跳转到ui.outputtype部分,而不循环遍历文件并检查键值。
有没有办法做到这一点?
您应该加载属性,然后可以通过其键获取值:
Properties props = new Properties();
props.load(new FileInputStream("my.properties"));
props.getProperty("ui.outputtype.snapshot");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10067 次 |
| 最近记录: |