I have a StringWriter, sw variable that is populated by the FreeMarker template. Once I filled sw , how can I print it in a text file?
I have a for loop as follows:
for(2 times) { template.process(data, sw); out.println(sw.toString()); }
Now I'm just displaying it. How to do this for a file? I assume that with each cycle my sw will be changed, but I want the data from each cycle to be added together to the file.
Edit: I tried the code below. When it starts, it shows that the file.txt parameter file.txt been changed, but when it restarts, the file still contains nothing.
sw.append("CheckText"); PrintWriter out = new PrintWriter("file.txt"); out.println(sw.toString());
java file-io stringwriter
user1460557
source share