I’ve been having issues with a Java File.
Its designed to write line after line in a test file as a log. Unfortunately it overwrites the same line every time I call it.
If anyone can help I would be eternally grateful as this has been driving me up the wall!
Code Below. Thanks.
public abstract class Log {
protected static String DefaultLogFileLocation = "c:\\LOG.txt";
public static void ToFile(String pInputString){
{
FileOutputStream pOUTPUT;
PrintStream pPRINT;
try
{
pOUTPUT = new FileOutputStream(DefaultLogFileLocation);
pPRINT = new PrintStream(pOUTPUT);
pPRINT.println (pInputString + "\n");
pPRINT.close();
}
catch (Exception e)
{
System.err.println ("Error writing to file");
}
}
}
}