Modifications de la V1

This commit is contained in:
2024-11-14 19:21:56 +01:00
parent 57fcd8f1af
commit 3597408ebe
17 changed files with 425 additions and 8 deletions

View File

@@ -0,0 +1,32 @@
package fr.monkhanny.dorfromantik.utils;
import java.io.*;
import java.util.*;
public class Environnement {
private static final String ENV_FILE = ".env";
private static final Properties properties = new Properties();
static {
loadEnvironmentVariables();
}
private static void loadEnvironmentVariables() {
try (InputStream input = new FileInputStream(ENV_FILE)) {
// Chargement des variables du fichier .env
properties.load(input);
} catch (IOException e) {
System.err.println("Erreur lors du chargement du fichier .env : " + e.getMessage());
}
}
// Méthode pour récupérer une variable d'environnement, renvoie null si non trouvé
public static String getEnv(String key) {
return properties.getProperty(key);
}
// Méthode pour vérifier si une variable d'environnement est présente
public static boolean hasEnv(String key) {
return properties.containsKey(key);
}
}