I am trying to redirect the console input to a file. Problem is that every time i create a file it overwrites it or creates new files if I select the name of file to include unix timestamp. I saw similar questions here but I am not sure which approach or class to use.
    PrintStream out;
    PrintStream oldout = new PrintStream(System.out);
    try {
        out = new PrintStream(
                new FileOutputStream(
                        workFolder + File.separator + "output" + Instant.now().getEpochSecond() + ".txt"));
         System.setOut(out);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
System.setOut(oldout);
So if there isn't a file to create it, but if there is already a file to just append new data, but not overwrite or create new files.
 
    