import com.google.zxing.BarcodeFormat;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import java.io.OutputStream;
public class ZXingCodeUtil {
public static void generatorCode(String url, OutputStream outputStream) throws Exception {
QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix bitMatrix = qrCodeWriter.encode(url, BarcodeFormat.QR_CODE, 60, 60);
MatrixToImageWriter.writeToStream(bitMatrix, "PNG", outputStream);
}
}
Google zxing 生成 QRcode
最新推荐文章于 2023-12-31 16:20:43 发布