31 lines
727 B
Java
31 lines
727 B
Java
package aadd.palomafp.anp.conexion;
|
|
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.util.Properties;
|
|
|
|
|
|
public class ConfigConexion {
|
|
|
|
private static final String RUTA_CONFIG = "ficheros/config.properties";
|
|
private static final Properties PROPS = new Properties();
|
|
|
|
static {
|
|
try (FileInputStream fis = new FileInputStream(RUTA_CONFIG)) {
|
|
PROPS.load(fis);
|
|
} catch (IOException e) {
|
|
throw new IllegalStateException("No se pudo leer" + RUTA_CONFIG, e);
|
|
}
|
|
}
|
|
|
|
private ConfigConexion() {}
|
|
public static String get(String clave) {
|
|
String valor = PROPS.getProperty(clave);
|
|
if (valor == null) {
|
|
System.out.println("Falta la propiedad: " + clave);
|
|
}
|
|
|
|
return valor;
|
|
}
|
|
}
|