Ответ 1
- Создайте новый файл из меню "Файл". Или нажмите Ctrl + N
- Вместо имени файла напишите config.properties, затем нажмите "Готово"
Затем вы можете добавить свойства вашего файла свойств, как это
dbpassword=password
database=localhost
dbuser=user
Пример загрузки свойств
public class App {
public static void main(String[] args) {
Properties prop = new Properties();
InputStream input = null;
try {
input = new FileInputStream("config.properties");
// load a properties file
prop.load(input);
// get the property value and print it out
System.out.println(prop.getProperty("database"));
System.out.println(prop.getProperty("dbuser"));
System.out.println(prop.getProperty("dbpassword"));
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}