/** * Uses the specified OutputStream for writing. * */ protected final void openOutputStream(OutputStream outputStream) { assertNotAlreadyOpen(); try { if (this.useCompression == null || this.useCompression) { this.writer = new BufferedWriter(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)); } else { this.writer = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(outputStream), StandardCharsets.UTF_8)); } } catch (IOException e) { throw new UncheckedIOException(e); } }
/** * Opens the specified file for writing. * * @param filename * @throws UncheckedIOException */ protected final void openFile(final String filename) throws UncheckedIOException { assertNotAlreadyOpen(); if (this.useCompression == null) { this.writer = IOUtils.getBufferedWriter(filename); } else { this.writer = IOUtils.getBufferedWriter(filename, this.useCompression); } }