Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String message = properties.getProperty("text.message");
- String formattedMessage = MessageFormat.format(message, "Richard", "School", new Date(), "1days");
- System.out.println(formattedMessage); // Richard has to go to School in 31/05/2012 / 1days
- String pattern = "{0} has to go to {1} in {2,date} / {3,number,integer} days.";
- String result = MessageFormat.format(pattern, "Richard", "school", new Date(), 5);
- System.out.println(result);
- Richard has to go to school in 31-May-2012 / 5 days.
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.OutputStream;
- import java.util.Properties;
- public class App {
- public static void main(String[] args) {
- Properties prop = new Properties();
- OutputStream output = null;
- try {
- output = new FileOutputStream("config.properties");
- // set the properties value
- prop.setProperty("database", "localhost");
- prop.setProperty("dbuser", "ayushman");
- prop.setProperty("dbpassword", "password");
- // save properties to project root folder
- prop.store(output, null);
- } catch (IOException io) {
- io.printStackTrace();
- } finally {
- if (output != null) {
- try {
- output.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
- }
- #Fri Jan 17 22:37:45 MYT 2014
- dbpassword=password
- database=localhost
- dbuser=ayushman
- Properties properties = ObjectProperties.readObjects("HomePageObject.properties");
- System.out.println(properties.getProperty("clusterNameXpath"));
- String dummystring = (String) properties.get("clusterNameXpath");
- clusterNameXpath = MessageFormat.format(dummystring, "des01500");
- System.out.println(clusterNameXpath);
- //a[contains(text(),'{0}')]
- //a[contains(text(),{0})]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement