Skip to content

Commit

Permalink
Create QR code website
Browse files Browse the repository at this point in the history
  • Loading branch information
aleon1220 committed Dec 7, 2023
1 parent e850efd commit 76fd471
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/java/service/GenerateQRCode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package service;

import java.io.IOException;
import java.nio.file.Paths;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;

public class GenerateQRCode {

public void createWebsiteQRCode() throws WriterException, IOException {
String qrData = "www.andres.nz";
String localPath = "/home/aleonrangel";
boolean validateQR = false;

BitMatrix matrix = new MultiFormatWriter().encode(qrData, BarcodeFormat.QR_CODE, 500, 500, null);
MatrixToImageWriter.writeToPath(matrix, "png", Paths.get(localPath), null);
System.out.println("QR code created");
validateQR = true;
}
}

0 comments on commit 76fd471

Please sign in to comment.