/** * This method wraps the output stream with the * corresponding compression method * * @param ostream output stream * @return output stream with on-the-fly compression * @exception IOException thrown if file is not writable */ private OutputStream compress(final OutputStream ostream) throws IOException { final String v = getValue(); if (GZIP.equals(v)) { return new GZIPOutputStream(ostream); } if (XZ.equals(v)) { return newXZOutputStream(ostream); } if (BZIP2.equals(v)) { ostream.write('B'); ostream.write('Z'); return new CBZip2OutputStream(ostream); } return ostream; }