I'm trying to write some test messages or some text content to file through java in ofbiz framework. If the file already has content, recent messages has to append at bottom of file.
In brief, I want a functionality like Debug.log in ofbiz. As it writes everything to debug.log file, I want a separate file to write my text messages.
I tried this,
File file = new File("/applications/party/webapp/partymgr/test.txt");
if (!file.exists()) {
try {
file.createNewFile();
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
Debug.logInfo("writing...........", module);
bw.write("this is first line in file");
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
But it is throwing FileNotFoundException
.
As, I'm not expert in ofbiz, i'm not sure about the file path. If file path is the problem please suggest me solution.