Jerry Jacob's Blog

Passing Arguments to .property file

Posted in Java/ J2EE by jerlinworld 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);

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: