In this tutorial, we will generate a code that will give us the information stored in the QR Code as output using Java. We can say that we will write code that will decode the QR Code.
QR Code to Text converter in Java
We can generate our code using any IDE ie. Notepad, Notepad++, Netbeans, Eclipse, etc.
package javaapplication29; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import com.google.zxing.*; import com.google.zxing.client.j2se.BufferedImageLuminanceSource; import com.google.zxing.common.HybridBinarizer; public class NewClass { public static void main(String args[])throws IOException, NotFoundException{ File fileobj = new File("C:\\Users\\lenovo\\Desktop\\kamal\\qrcode.png"); BufferedImage bfrdImgobj = ImageIO.read(fileobj); LuminanceSource source = new BufferedImageLuminanceSource(bfrdImgobj); BinaryBitmap binarybitmapobj = new BinaryBitmap(new HybridBinarizer(source)); Result resultobj = new MultiFormatReader().decode(binarybitmapobj); System.out.println("Data Stored In our QR Code" +" " + resultobj.getText()); } }
Output: