Problem writing multiple strings to a text file
I am writing a program where I will have to write many Strings into a text file, so I want to create a separate method to which I can pass a String and it will write the String to a new line in the file. But how many Strings I may pass it only writes the last one. Can someone please help me debug.
Here is the code:
Here I want to write 3 strings to a particular file , I dont want to copy code for all file readers and writers everytime I have to write.
public class Example
public static void main(String args)
Example ex = new Example();
ex.logFile = "log0.txt";
public void log(String str)
fileWrite = new BufferedWriter(new FileWriter(logFile));
System.out.println("Error : cannot write into log file");
Thanks and Regards