public static void setCode() throws Exception {
   String filePath = "/home/static/images/";
   String fileName = "dcn.png";
   JSONObject json = new JSONObject();
   json.put("dcn", "http://kf.d.cn");
   //        String content = json.toJSONString();
   String content = "http://kf.d.cn";
   int width = 200;
   int height = 200;
   String format = "png";
   Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>();
   hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
   BitMatrix bitMatrix =
       new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
   Path path = FileSystems.getDefault().getPath(filePath, fileName);
   MatrixToImageWriter.writeToPath(bitMatrix, format, path);
 }