I create a web service using JAVA. I want to create a log file in the server to recover it later but my problem is that I cannot save the file due to client rights. In my local server, I can save it in the root path, but in the Devian server where I will use it, this is not possible. I try to change the path, but the problem remains because my local paths are different than other server. This is my code:
BufferedWriter bw = null;
FileWriter fw = null;
try {
File file = new File(System.getProperty("user.dir")+File.separator+"zlm_"+thoy+".txt");
// Si el archivo no existe, se crea!
if (!file.exists()) {
file.createNewFile();
}
// flag true, indica adjuntar información al archivo.
fw = new FileWriter(file.getAbsoluteFile(), true);
bw = new BufferedWriter(fw);
bw.write(entrada+";"+porcentaje+";");
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
//Cierra instancias de FileWriter y BufferedWriter
if (bw != null)
bw.close();
if (fw != null)
fw.close();
} catch (IOException ex)
{
ex.printStackTrace();
}
}
Any ideas?