public static void main(String[] args)
{
//大小
int width=300;
int height=300;
//格式
String format = "png";
//内容
String content ="www.baidu.com";
//定义二维码参数
HashMap hints = new HashMap();
hints.put(EncodeHintType.CHARATEA_SET,"utf-8");//二维码形式
hints.put(EncodeHintType.ERROR_CORRECTION.ErrorCorrectionLEvel.M);//二维码纠错等级
hints.put(EncodeHintType.MAEGIN,2);//大小
try {
//实用图片处理类处理二维码
BitMatrix bitMatrix = new MultiFormatWriter().encode(content,BarcodeFormat.QR_CODE,width,height,hints);
//二维码保存路径Path file = new File("C:/java/img.png").toPath();
//使用方法生成二维码到该路径
} catch (Exception e) {
e.printStackTrace();
}
}