Close the streams so that the temporary files can be deleted. File.deleteOnExit() cannot be used because the stdout and stderr files are inside a folder, and have to be deleted before the folder itself is deleted, which can't be guaranteed when using the deleteOnExit() method.
()
| 176 | * the deleteOnExit() method. |
| 177 | */ |
| 178 | static public void shutdown() { |
| 179 | // replace original streams to remove references to console's streams |
| 180 | System.setOut(systemOut); |
| 181 | System.setErr(systemErr); |
| 182 | |
| 183 | cleanup(consoleOut); |
| 184 | cleanup(consoleErr); |
| 185 | |
| 186 | // also have to close the original FileOutputStream |
| 187 | // otherwise it won't be shut down completely |
| 188 | cleanup(stdoutFile); |
| 189 | cleanup(stderrFile); |
| 190 | } |
| 191 | |
| 192 | |
| 193 | static private void cleanup(OutputStream output) { |
no test coverage detected