I've got Problems, when I try to generate a file in order to write into. I don't get any exceptions and the sysouts are also displayed, but the File is not generated.. Is there something I don't see..? this is the class, which does everything:
public class GraphMLWriter {
public FileWriter writer;
public File file;
private static GraphMLWriter instance;
private GraphMLWriter() {
initFile();
}
public void initFile() {
file = new File("myFile.txt");
try {
writer = new FileWriter(file, true);
System.out.println("File erzeugt");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void writeToFile() {
try {
writer.write("tolltoll");
writer.write(System.getProperty("line.separator"));
writer.write("es klappt");
writer.flush();
writer.close();
System.out.println("File geschrieben");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static synchronized GraphMLWriter getInstance() {
if (instance == null) {
instance = new GraphMLWriter();
}
return instance;
}
}
And it is called like this:
writer = GraphMLWriter.getInstance();
writer.writeToFile();
for the context: I've got a Spring 3 Application which connects to a Database and I want to write result sets into a generated xml-File! I just copied the code from another application where it worked properly