How to add space at the end of property value
Asked Answered
L

2

28
label.my.answer=My Answer

I would like to add spaces deliberately at the end of the above key (e.g. I would like to have 2 spaces at the end "My Answer ")

Currently the java.util.ResourceBundle functionality kind of trims this piece of code while retrieving the value

Lombard answered 4/6, 2011 at 6:55 Comment(0)
W
57
label.myAnswer = My Answer\u0020\u0020

Note: identifiers with dots usually represent a hierarchy of names, and my is not a hierarchy level. You would certainly not define a Java class or a Java package of that name, would you?

Wertheimer answered 4/6, 2011 at 7:4 Comment(5)
But you wouldnt create a package named myAnswer either... As long as the name expresses well what its for who cares? Beside of that +1 for the answerUnwinking
For example, the Eclipse Resource Bundle Editor cares. You can configure it that it regards dots as hierarchical separators, which are then displayed in a tree. You wouldn't want to have "my" as a node in that tree.Wertheimer
In this conext I have to say that you are right. Didnt know about this plugin so +1 for your comment for that. Unfortunately I dont find any download information about the derived Babel editor.Unwinking
No problem. Many developers that I know just stick to the naming convention of "putting dots where I like" and don't think about the semantic implications.Wertheimer
That solution doesn't work in Spring Boot 2.0.3.RELEASECardiovascular
Q
5

Also

label.myAnswer = My Answer\ \ 
Quadrinomial answered 4/5, 2017 at 19:5 Comment(4)
this continues the property in the next line - not intendedUnivalence
No, it doesn't: look closer. The final backslash is not at the end of the line.Quadrinomial
you are correct. Actually ResourceBundle should not trim the spaces, Property files are allowed to have trailing spaces. Which however I consider bad design and equally bad practice.Univalence
You don't need to pick on me just because you were wrong.Quadrinomial

© 2022 - 2024 — McMap. All rights reserved.