Last active
July 20, 2017 14:45
-
-
Save andgomes/39259fb563597def52f94820c532d151 to your computer and use it in GitHub Desktop.
Classe que carrega e lê duas propriedades de um arquivo de resource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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