public static void writeBytesToStream(byte[] bytes,OutputStream outputStream) throws IOException {
  BufferedOutputStream bos=new BufferedOutputStream(outputStream);
  try {
    bos.write(bytes);
  }
  finally {
    bos.close();
  }
}

public static void writeBytesToStream ( byte [ ] bytes , OutputStream outputStream ) throws IOException { BufferedOutputStream bos = new BufferedOutputStream ( outputStream ) ; try { bos . write ( bytes ) ; } finally { bos . close ( ) ; } }
writes given bytes array to given outputstream . closes outputstream afterwards .
