I am currently tring to store data in a file that is going to be called questions.list (a file object)However i am unable to this, i suspect there a few problems/missing parts in my code(as i have a very basic knowledge on objects). Could anyone please help me achieve this or help provide me with a better understanding of what i am doing wrong? thanks.
import java.util.Scanner;
import java.io.*;
public class Practice {
/**
*large amount of code
*/
String answer = alpha4;
System.out.println(answer);
}
/**
* Method for saving information to a file 'questions.list'
*/
public static void printToFile(String userInformationToBePrinted)
throws IOException {
PrintWriter fileWriter = new PrintWriter(
new BufferedWriter(
new FileWriter("questions.list", true)));
fileWriter.append(userInformationToBePrinted + "\n");
fileWriter.close();
I am guessing i am missing some code. If the question is not clear please feel free to ask any questions.