Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. String message = properties.getProperty("text.message");
  2. String formattedMessage = MessageFormat.format(message, "Richard", "School", new Date(), "1days");
  3. System.out.println(formattedMessage); // Richard has to go to School in 31/05/2012 / 1days
  4.  
  5. String pattern = "{0} has to go to {1} in {2,date} / {3,number,integer} days.";
  6. String result = MessageFormat.format(pattern, "Richard", "school", new Date(), 5);
  7. System.out.println(result);
  8.  
  9. Richard has to go to school in 31-May-2012 / 5 days.
  10.  
  11. import java.io.FileOutputStream;
  12. import java.io.IOException;
  13. import java.io.OutputStream;
  14. import java.util.Properties;
  15.  
  16. public class App {
  17. public static void main(String[] args) {
  18.  
  19. Properties prop = new Properties();
  20. OutputStream output = null;
  21.  
  22. try {
  23.  
  24. output = new FileOutputStream("config.properties");
  25.  
  26. // set the properties value
  27. prop.setProperty("database", "localhost");
  28. prop.setProperty("dbuser", "ayushman");
  29. prop.setProperty("dbpassword", "password");
  30.  
  31. // save properties to project root folder
  32. prop.store(output, null);
  33.  
  34. } catch (IOException io) {
  35. io.printStackTrace();
  36. } finally {
  37. if (output != null) {
  38. try {
  39. output.close();
  40. } catch (IOException e) {
  41. e.printStackTrace();
  42. }
  43. }
  44.  
  45. }
  46. }
  47. }
  48.  
  49. #Fri Jan 17 22:37:45 MYT 2014
  50. dbpassword=password
  51. database=localhost
  52. dbuser=ayushman
  53.  
  54. Properties properties = ObjectProperties.readObjects("HomePageObject.properties");
  55. System.out.println(properties.getProperty("clusterNameXpath"));
  56. String dummystring = (String) properties.get("clusterNameXpath");
  57. clusterNameXpath = MessageFormat.format(dummystring, "des01500");
  58. System.out.println(clusterNameXpath);
  59.  
  60. //a[contains(text(),'{0}')]
  61. //a[contains(text(),{0})]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement