How can I achieve the following, where prefsOutputStream is the pseudo-variable I'm aiming to make:
PrintStream oldOut = System.out;
System.setOut(prefsOutputStream);
System.out.println("Foo Bar");
String logString = Preferences.userRoot().node("app").get("stdout","");
oldOut.println(logString); // Outputs "Foo Bar" into the console