This post explains Sample INI File example and INI cheatsheet

Sample INI File example


# config.ini file
# Applicaiton settings

# http settings
[http]
port=8080
username=httpuser

# https settings
[https]
port=8043
username=httpsuser

# ftp settings
[FTP]
port=8043
username=ftpuser

# database settings
[database]
driverclass   = com.mysql.jdbc.Driver
dbName        = mydatabase
port          = 3306
username      = root
password      = secure # not recommended to store secure information
# feature settings
[settings]
enable_ssl = true
enable_2mf =  true

INI file cheat sheet

Comment syntax starts with a semicolon ; followed by comment text. Section or header are declared new line with square brackets[] followed by key and values options should be declared with the same key and multiple values Each line of an element contains keys and values.

values of any type, String, number, boolean, enum, array, or map

; One way to write comment syntax
# Another way to write comment syntax
; sections defined with multiple values
[Section-name]
key=value

; sections defined with multiple values
option1=true # in-line comments
option1=false

; different values of data

number1=123
number1_hexa=0x123
number1_octa=0123
number1_binary=0b1111
float_number1=123.12

;boolean values
value1=true
value2=false

; Application Configuration Settings

[Database]
; Database server address
server = localhost

; Database port number
port = 3306

[User]
; Admin username
username = admin

; Admin password (avoid including actual passwords in comments!)
password = secret

 ; Application Settings

[application]
host = "localhost"
port = 8080

[feature]
is_ssl = true
feature_enabled =  true

# use prefix and suffix triple quotes for Multi line values declaration


key = """
This is a
multi-line
value.
"""
  • the key is a valid identifier that will not contain = or ; symbols.
  • The value is the valid identifier of any string
  • Key can be String, number, or Boolean values.