Haber al final la clase ha quedado asi:
public class ApplicationDirectories {
static private ApplicationDirectories singleton = new ApplicationDirectories();
public ApplicationDirectories() {
}
public void crearApplicationDirectories
(File configFile
) {
try {
System.
out.
println(configFile.
getPath()); prop.load(is);
} //end RepositoryManagement()
/**
* **GETTERS**
*/
/**
* Returns the singleton attribute which is used to access the methods of this class from other packages
* @return a RepositoryManagement object
*/
static public ApplicationDirectories getSingleton() {
return singleton;
}
return prop;
}
/**
* **SETTERS**
*/
this.prop=prope;
}
}
Y al inicio del programa hago lo siguiente:
String pathSeparator
= System.
getProperty("file.separator");
File configDir
= new File(System.
getProperty("user.home").
concat(pathSeparator
+ ".Jsignalworkbench" + pathSeparator
+ "Config")); File configFile
= new File (System.
getProperty("user.home").
concat(pathSeparator
+ ".Jsignalworkbench" + pathSeparator
+ "Config" + pathSeparator
+ "config.txt")); File appDir
= new File (System.
getProperty("user.home").
concat(pathSeparator
+ ".Jsignalworkbench"));
if(configFile.exists()){
global.ApplicationDirectories.getSingleton().crearApplicationDirectories(configFile);
}
else{
if(!appDir.exists()){
//File aux = new File(global.ApplicationDirectories.getSingleton().getProperties().getProperty("appDir"));
//global.ApplicationDirectories.getSingleton().ApplicationDirectories(configFile);
//if (!aux.exists()){
//File dir = new File(System.getProperty("user.home").concat(pathSeparator + ".Jsignalworkbench"));
if(!appDir.mkdir()){
JOptionPane.
showMessageDialog(null,
"Error in the creation of a directory needed for the program to run",
"Error",
JOptionPane.
ERROR_MESSAGE);
}
}
if(!configDir.exists()){
if(!configDir.mkdir()){
JOptionPane.
showMessageDialog(null,
"Error in the creation of a directory needed for the program to run 1",
"Error",
JOptionPane.
ERROR_MESSAGE);
}
//Creation of the configFile file
try {
// A partir del objeto File creamos el fichero físicamente
if (!configFile.createNewFile()){
JOptionPane.
showMessageDialog(null,
"Error in the creation of a file needed for the program to run",
"Error",
JOptionPane.
ERROR_MESSAGE); }
else
System.
out.
println("Fichero de configuracion creado correctamente");
ioe.printStackTrace();
}
System.
out.
println("fichero de config creado"); System.
out.
println(configFile.
getPath()); //Write configFile data to the configFile file
String lineSeparator
= System.
getProperty("line.separator");
bw.write("***CONFIG FILE***" + lineSeparator);
//bw.write("homeDir =" + homeDir + lineSeparator);
//String tmpDir = System.getProperty("java.io.tmpdir");
//bw.write("tmpDir =" + tmpDir + lineSeparator);
String defaultRepositoriesPath
= homeDir
+ pathSeparator
+ ".Jsignalworkbench" + pathSeparator
+ "Repositories"; bw.write("defaultRepositoriesPath =" + defaultRepositoriesPath + lineSeparator);
String defaultRemotePath
= "http://arregla-tu-pc.no-ip.biz/pruebas_proyecto/gasuco.xml"; bw.write("defaultRemotePath =" + defaultRemotePath + lineSeparator);
//String appDir = homeDir + pathSeparator + ".Jsignalworkbench";
//bw.write("appDir =" + appDir + lineSeparator);
String localPlugins
= appDir
+ pathSeparator
+ "Local_plugins"; bw.write("localPlugins =" + localPlugins + lineSeparator);
bw.close();
global.ApplicationDirectories.getSingleton().crearApplicationDirectories(configFile);
}
}
System.
out.
println(global.
ApplicationDirectories.
getSingleton().
getProperties().
size()); System.
out.
println(global.
ApplicationDirectories.
getSingleton().
getProperties().
getProperty("localPlugins"));
File repoDir
= new File(global.
ApplicationDirectories.
getSingleton().
getProperties().
getProperty("defaultRepositoriesPath")); if(!repoDir.exists()){
System.
out.
println("No esxiste defaultRep path"); if(!repoDir.mkdir()){
JOptionPane.
showMessageDialog(null,
"Error in the creation of a directory needed for the program to run",
"Error",
JOptionPane.
ERROR_MESSAGE);
}
}
File plugDir
= new File(global.
ApplicationDirectories.
getSingleton().
getProperties().
getProperty("localPlugins")); if(!plugDir.exists()){
if(!plugDir.mkdir()){
JOptionPane.
showMessageDialog(null,
"Error in the creation of a directory needed for the program to run",
"Error",
JOptionPane.
ERROR_MESSAGE);
}
}
}
El problema viene que cuando saco por pantalla
System.
out.
println(global.
ApplicationDirectories.
getSingleton().
getProperties().
getProperty("localPlugins"));
me sale sin los separadores de path, es decir asi: C:Usersgasuco.JsignalworkbenchLocal_plugins....
Si miro dentro del fichero si que sale con las \. Que esta pasando???
Salu2
alzehimer_cerebral