/** * Assigns the output PrintStream to a temporary text file. This is because parts of the JMusic * package produce a lot of output to the console which isn't needed and clutters up the console. * * @return a copy of the original System.out PrintStream, for later re-assignment */ static PrintStream divertStandardOutput() { // Save the current standard input, output, and error streams // for later restoration. PrintStream origOut = System.out; try { File output = new File("temp_output.txt"); output.createNewFile(); } catch (Exception e) { e.printStackTrace(origOut); } try { System.setOut(new PrintStream(new FileOutputStream("temp_output.txt"))); } catch (Exception e) { e.printStackTrace(origOut); } return origOut; }