Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Info

This directory contains a replica of basic ini file parser java project by Ángel Luis and a minor modifications to that project.

Usage

  • build app
mvn package
  • write the file custom.properties in the launcher directory:
USERNAME=defined
# will be overridden by system property with the same name
option1=user:${USERNAME}
FOO=bar
option2=FOO:${FOO}

in the right hand side one can use properties just defined except when the property name collides with predefined ones like USERNAME on WINDOW or HOME on Unix. you can update the file any time

  • run the app, which will simply echo the read values of few options
set debug=false
java -cp target\iniparser-0.3-SNAPSHOT.jar example.test.Test

or on Linux

DEBUG=false java -cp target/iniparser-0.3-SNAPSHOT.jar example.test.Test
option1: user:Serguei
option2: FOO:bar
option3: default value for option3

NOTE: the output will be different on Linux where is no USERPROFILE environment variable

  • remove the file custom.properties and rerun. The custom.properties resource will be read
rm -f ./custom.properties
mvn clean package
DEBUG=true java -cp target/iniparser-0.3-SNAPSHOT.jar example.test.Test
Reading properties file: 'C:/developer/sergueik/selenium_java/ini_parser/custom.properties'
Reading properties resource stream: 'custom.properties'
Reading: 'option2' = 'FOO:${FOO}'
getting property: FOO
system property: null
environment property: bar
Reading: 'option1' = 'user:${USERNAME}'
getting property: USERNAME
system property: null
environment property: Serguei
Reading: 'FOO' = 'bar'
Reading: 'USERNAME' = 'defined'
getting property: option1
system property: user:Serguei
option1: user:Serguei
getting property: option2
system property: FOO:bar
option2: FOO:bar
getting property: option3
system property: null
environment property: null
option3: default value for option3
  • temporarily remove the file src/main/resources/custom.properties and rebuild and rerun. The custom.properties resource will be read
rm -f src/main/resources/custom.properties
mvn clean package
DEBUG=true java -cp target/iniparser-0.3-SNAPSHOT.jar example.test.Test
debug: true
fileName: C:/developer/sergueik/selenium_java/ini_parser/custom.properties
Reading properties file: 'C:/developer/sergueik/selenium_java/ini_parser/custom.
properties'
Reading properties resource stream: 'custom.properties'
getting property: option1
system property: null
environment property: null
option1: default value for option1
getting property: option2
system property: null
environment property: null
option2: default value for option2
getting property: option3
system property: null
environment property: null
option3: default value for option3

See also:

Author

Serguei Kouzmine