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.
()
| 168 | * the deleteOnExit() method. |
| 169 | */ |
| 170 | static public void shutdown() { |
| 171 | // replace original streams to remove references to console's streams |
| 172 | System.setOut(systemOut); |
| 173 | System.setErr(systemErr); |
| 174 | |
| 175 | cleanup(consoleOut); |
| 176 | cleanup(consoleErr); |
| 177 | |
| 178 | // also have to close the original FileOutputStream |
| 179 | // otherwise it won't be shut down completely |
| 180 | cleanup(stdoutFile); |
| 181 | cleanup(stderrFile); |
| 182 | } |
| 183 | |
| 184 | |
| 185 | static private void cleanup(OutputStream output) { |
no test coverage detected