Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do curly braces inside a java property file mean?

We have many property files inside our java project. I don't understand the meaning of the integer values inside the curly braces.
Example:
validation.error=Input Validation Failed for field:[{0}]. Reason:[{1}]

like image 329
Amzi Avatar asked Oct 03 '13 20:10

Amzi


3 Answers

They are for use with the MessageFormat class. Something of the form {n}, where n is a number, is a placeholder for a dynamic value.

There are additional things you can add to the placeholder for formatting purposes; see the linked Javadocs above for more information.

like image 53
rgettman Avatar answered Oct 10 '22 02:10

rgettman


They're placeholders for parameters. When used, two parameters would be passed to indicate the name of the field and the reason for failure.

like image 32
Kayaman Avatar answered Oct 10 '22 01:10

Kayaman


The curly brackets are placeholders.

You can use placeholders in your messages and replace them with location-appropriate values at runtime based on the semantics of your user's language. For this you use the MessageFormat class.

like image 23
Philipp Sander Avatar answered Oct 10 '22 03:10

Philipp Sander