code: public static OutputStream asBufferedOutputStream(OutputStream os) {
          if (os instanceof BufferedOutputStream || os instanceof ByteArrayOutputStream) {
              return os;
          }
          return new BufferedOutputStream(os);
      }
docs: Ensures that the returned stream is a buffered version of the supplied output stream. The result must not
  necessarily be an instance of {@link BufferedOutputStream}, it can also be, e.g., a {@link ByteArrayOutputStream},
  depending on the type of the supplied output stream.
  
  @param os
  the output stream
  
  @return a buffered version of {@code os}