se crea una clase la nombre -> ConfigsGetter
//es la localizacion donde esta nuestro archivo de propertis
private static final String BUNDLE_NAME = "/res/config/file.properties";
public ConfigsGetter() {
}
public static String getString(String key) {
try {
InputStream in = ConfigsGetter.class.getResourceAsStream(BUNDLE_NAME);
if (in == null ) {
System.out.println("Properties file: " + BUNDLE_NAME + " not found!");
}
else {
Properties pro = new Properties();
pro.loadFromXML(in);
return pro.getProperty(key);
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
en el archivo file.properties
para llamarlo
ConfigsGetter.getString("plantilla")
No hay comentarios:
Publicar un comentario