Skip to content

Instantly share code, notes, and snippets.

@andgomes
Last active July 20, 2017 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andgomes/39259fb563597def52f94820c532d151 to your computer and use it in GitHub Desktop.
Save andgomes/39259fb563597def52f94820c532d151 to your computer and use it in GitHub Desktop.
Classe que carrega e lê duas propriedades de um arquivo de resource
package org.andgomes;
import java.io.InputStream;
import java.io.IOException;
import java.util.Properties;
public class PropertiesReader {
public static void main(String[] args) throws IOException {
InputStream inputStream = PropertiesReader.class.getClassLoader().
getResourcesAsStream("my.properties");
Properties prop = new Properties();
prop.load(inputStream);
String username = prop.getProperty("username");
String password = prop.getProperty("password");
System.out.println("Username: " + username);
System.out.println("Password: " + password);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment