Jerry Jacob's Blog

Passing Arguments to .property file

Posted in Java/ J2EE by Jerry Jacob on February 24, 2010

Property File Sample

app.welcome= Welcome {0} and {1}.
app.bye=Bye {0} and {1}.

Jave Code using MessageFormat

String propText=resBundle.getString("app.welcome");
java.text.MessageFormat msgFormatter = new java.text.MessageFormat(propText);

// Write the dynamic args you want to replace 
Object[] messageArguments = {"Jerry","Jacob"};  
String finalText= msgFormatter.format(messageArguments);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: