I am trying to write into a single text file through different classes. I opened the text file from the main class:
public static void main( String[] args ) throws Exception {
BufferedWriter writer = new BufferedWriter(new FileWriter("src/t1.txt"));
Parser.getParseTree().print(); // where I called the method
writer.close();
}
This is a print() method from another class:
public static void print() throws IOException {
BufferedWriter writer = new BufferedWriter(new FileWriter("src/t1.txt"));
writer.write("afcad fad fad");
}
The BufferedWriter writer = new BufferedWriter(new FileWriter("src/t1.txt"));
in print() method does not work and nothing prints into the t1.txt
file.