Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to jump to a section in a Java properties file?

I have a Java properties file that has lots of different properties in it for different things:

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

The file is a lot bigger than this.

I want to jump to the ui.outputtype section without looping through the file and checking the key value.

Is there a way to do this?

like image 582
nathj07 Avatar asked Dec 07 '25 08:12

nathj07


1 Answers

You should load the properties, and then you can get the value by its key:

Properties props = new Properties();
props.load(new FileInputStream("my.properties"));

props.getProperty("ui.outputtype.snapshot");
like image 137
Zed Avatar answered Dec 09 '25 20:12

Zed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!