How can I add stuff to the same text file throughout multiple methods? (cannot use parameters) Ie: public static String addOne(){ outputFile.print("add this string\n"); } public static String addTwo(){ outputFile.print("add this string too\n"); } public void print(){ FileWriter fwriter = new FileWriter("filename.txt"); PrintWriter outputFile = new PrintWriter(fwriter); } Code (markup): I know that the above code doesnt work (because the static add___ doesnt know what outputFile is).
'stuff' as in text... like, in addOne method, i want it to add: outputFile.println("\n **ERROR01** - Item number must be five characters\n"); and then later on, ill want it to add outputFile.println("\n **ERROR02** - Item number must start with 2 letters\n"); and then in addTwo method, i want to add: outputFile.println("\n **ERROR03** - Item number must be numeric in last 3 positions\n");