Java FileOutputStream String Schreiben

Ich habe Probleme mit einer Java-Datei. Es ist entworfen, um write line nach line in eine test-Datei als log. Leider überschreibt es die gleiche Linie, jedes mal, wenn ich es nenne.

Wenn jemand helfen kann, ich wäre unendlich dankbar, als diese wurde driving me up the wall!

Code Unten.

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");
        }
    }
}
Warum Sie nicht einige Java-Logging-Framework? E. g. Java.util.logging, log4j, etc?

InformationsquelleAutor Maull | 2010-06-22

Schreibe einen Kommentar