I have stored some messages in a resource bundle. I'm trying to format these messages as follows.
import java.text.MessageFormat;
String text = MessageFormat.format("You're about to delete {0} rows.", 5);
System.out.println(text);
Assume that the first parameter i.e the actual message is stored in a property file which is somehow retrieved.
The second parameter i.e 5 is a dynamic value and should be placed in the placeholder {0}
which doesn't happen. The next line prints,
Youre about to delete {0} rows.
The placeholder is not replaced with the actual parameter.
It is the apostrophe here - You're
. I have tried to escape it as usual like You\'re
though it didn't work. What changes are needed to make it work?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…