I want to print lines to a file. I have RSI from typing these eight lines of code so many times. @throws IOException
(File file)
| 534 | * @throws IOException |
| 535 | */ |
| 536 | static public PrintWriter createWriter(File file) throws IOException { |
| 537 | createPath(file); // make sure in-between folders exist |
| 538 | OutputStream output = new FileOutputStream(file); |
| 539 | try { |
| 540 | if (file.getName().toLowerCase().endsWith(".gz")) { |
| 541 | output = new GZIPOutputStream(output); |
| 542 | } |
| 543 | } catch (IOException e) { |
| 544 | output.close(); |
| 545 | throw e; |
| 546 | } |
| 547 | return createWriter(output); |
| 548 | } |
| 549 | |
| 550 | |
| 551 | /** |
no test coverage detected