Primer commit Actividad 1.9

This commit is contained in:
jxu4
2026-10-15 16:42:57 +02:00
parent 6f9bdb3d3c
commit b5b0a5e3ed
6 changed files with 66 additions and 32 deletions
+21 -14
View File
@@ -1,29 +1,36 @@
package org.palomafp.aadd.jx;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;
public class GestorPropiedad {
private static final String FICHERO_PROPIEDADES = "application.properties";
private static Properties propiedades = new Properties();
static {
Path ruta = Paths.get("config", "application.properties");
try (BufferedReader entrada = Files.newBufferedReader(ruta, StandardCharsets.ISO_8859_1)) {
propiedades.load(entrada);
try (InputStream is = GestorPropiedad.class.getClassLoader().getResourceAsStream(FICHERO_PROPIEDADES)) {
if (is == null) {
throw new RuntimeException("No se ha podido cargar el fichero de configuración: " + FICHERO_PROPIEDADES);
}
try (BufferedReader entrada = new BufferedReader(new InputStreamReader(is, StandardCharsets.ISO_8859_1))) {
propiedades.load(entrada);
}
} catch (IOException e) {
System.err.println("Error al cargar el archivo de propiedades: " + e.getMessage());
throw new RuntimeException("Error al cargar el archivo de propiedades: " + e.getMessage(), e);
}
}
public static String get(String clave) {
return propiedades.getProperty(clave);
}