Property-файлы
db.host = http://localhost:8888/mydb
db.login = root
db.password = dbrootimport java.io.*;
import java.util.Properties;
public class Main {
public static void main(String[] args) {
FileInputStream fis;
Properties property = new Properties();
try {
fis = new FileInputStream("src/main/resources/config.properties");
property.load(fis);
String host = property.getProperty("db.host");
String login = property.getProperty("db.login");
String password = property.getProperty("db.password");
System.out.println("HOST: " + host
+ ", LOGIN: " + login
+ ", PASSWORD: " + password);
} catch (IOException e) {
System.err.println("ОШИБКА: Файл свойств отсутствует!");
}
}
}Last updated