Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. package org.andgomes;
  2.  
  3. import java.io.InputStream;
  4. import java.io.IOException;
  5. import java.util.Properties;
  6.  
  7. public class PropertiesReader {
  8.  
  9. public static void main(String[] args) throws IOException {
  10.  
  11. InputStream inputStream = PropertiesReader.class.getClassLoader().
  12. getResourcesAsStream("my.properties");
  13.  
  14. Properties prop = new Properties();
  15. prop.load(inputStream);
  16.  
  17. String username = prop.getProperty("username");
  18. String password = prop.getProperty("password");
  19.  
  20. System.out.println("Username: " + username);
  21. System.out.println("Password: " + password);
  22.  
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement