Sometimes, We want to include special characters in value of properties file. The properties file is an complete features described below with example

  • Inline Comments
  • key and value pair
  • Encoding
  • Unicode
  • Key and value contains spaces
  • Key and value contains special characters which is escaped by backslash

Let’s see an java properties file example

# application.properties
# This is one way to write a comments in properties
! this is a another way to write a comment in properties
name=john

## key can contain spaces with escape by backslash
full\ name= john 
# value can be spaces
full\ name= john\ anderw

# Any special characters (:,=,\,@) are escape in key and values
path=c:\\path
name=firstname\:john,lastname\=andrew
support.email=support\\@domain.com
hr\:email=hr\\@domain.com


# unicode
location=\u005ctmp

selectquery= select * from table where id=10

Conclusion

In this post, You learned sample properties file with all features with example