I am trying to become more independent in researching and finding solutions, but sometimes you hit a brick wall and it hurts. I was looking for a method to write at the end of the text inside the file. I looked on Oracle Documentation and it showed me this FileOutputStream and I normally use formatter method to print to a file. The constructor said that it would print at the end of file. Here it is: "Creates a file output stream to write to the file represented by the specified File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning. A new FileDescriptor object is created to represent this file connection. " So I was excited patted myself on my back a job well done got the code in, and what happens it deletes my info and writes over it. Luckily for me, I saved a back up of my text file just in case. Okay, I did not understand what they meant by " if the second argument is true", I only have one argument in my constructor so I am thinking did i do something wrong. Well, here is my code:
FileOutputStream fm = new FileOutputStream(f); String number = Integer.toString(IOquiz.Question1PlayerResponse); byte[]contentInBytes = number.getBytes(); fm.write(contentInBytes); fm.flush(); fm.close(); } catch(Exception Ex){ System.out.print("Trouble in China"); }
Thanks in advance