Tạo mã QR code với Zxing

Cài đặt dependency:

implementation group: 'com.google.zxing', name: 'core', version: '3.5.2'
implementation group: 'com.google.zxing', name: 'javase', version: '3.5.2'

code để tạo mã QR:

String data= "Tạo mã QR code";
QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix matrix = qrCodeWriter.encode(data, BarcodeFormat.QR_CODE, 200, 200);
        
String outputFile = "D:/demo/test.png";
Path path = FileSystems.getDefault().getPath(outputFile);
MatrixToImageWriter.writeToPath(matrix, "PNG", path);