Páginas

29 de enero de 2013

creacion de properties en un proyecto gwt




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!");
return null;
}
else {
Properties pro = new Properties();
pro.loadFromXML(in);
return pro.getProperty(key);
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
}

en el archivo  file.properties

key="plantilla">/res/config/fichero.xls
key="plantilla1">/res/config/fichero1.xls
key="plantilla2">/res/config/fichero2.xls
key="plantilla3">/res/config/fichero3.xls

para llamarlo 

ConfigsGetter.getString("plantilla")




No hay comentarios: