I'm trying to write into a xml file with Java.
private void writeToFile(){
// first checking the path and setting the file:
if(path.equals("errorlog")){
file = new File("errorlog.xml");
}else{
System.out.println("WRONG FILENAME");
return;
}
try {
fw = new FileWriter(file);
pw = new PrintWriter(fw);
System.out.println("LOG: "+log);
pw.println(log);
pw.close();
} catch (Exception e) {
e.printStackTrace();
System.out.println("ERROR: "+CLASSNAME);
}
}
Up to now I've found many examples in exact the same way, which are possible running. First I thought this might be, because something in the path of my file could be wrong (it's in the same package), but there is no exception and I've got another method which uses the same file and reads from it. Does anyone have an idea, what's going wrong right now? I'm grateful for any help
No comments:
Post a Comment