Actividad 1.9: properties en el classpath
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package org.palomafp.aadd.rmr;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Properties;
|
||||
|
||||
public class GestorPropiedades {
|
||||
|
||||
private static Properties propiedades = new Properties();
|
||||
|
||||
static {
|
||||
|
||||
try (InputStream entrada = GestorPropiedades.class.getResourceAsStream("/config/application.properties")) {
|
||||
propiedades.load(new InputStreamReader(entrada, StandardCharsets.ISO_8859_1));
|
||||
} catch (IOException | NullPointerException e) {
|
||||
System.err.println("Error al cargar el archivo de propiedades: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static String get(String clave) {
|
||||
return propiedades.getProperty(clave);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user