I 'v created a project that reads some of configuration from .properties file
public class PreferenceManager {
private int refreshTime;
private String[] filters;
Properties properties ;
public PreferenceManager() throws FileNotFoundException, IOException
{
properties = new Properties();
properties.load(ClassLoader.getSystemResourceAsStream ("preferences.properties"));
}
public void save() throws IOException, URISyntaxException
{
properties.setProperty("REFRESH_TIME", String.valueOf(refreshTime));
String filtersStr = "";
if(filters!= null){
for(String str : filters)
{
if((str == null)||(str.isEmpty())) continue;
filtersStr+= str.toUpperCase()+",";
}
}
properties.setProperty("FILTERS", filtersStr);
URI uri = ClassLoader.getSystemResource("preferences.properties").toURI();
File f = new File(uri);
properties.store(new FileOutputStream(f), null);
}
}
and every thing is ok . now I need to create a JAR file. I need to know how to make this JAR file read this properties file from the folder that contains it, because when the properties file is inside the JAR I can read it but I can write on it (Exception : URI is not hirarchal)
so I need ur Help please.
Thanks