Read QRCode in JAVA

Hello Friends,

As in earlier post we had learn what is QR code and how can we generate QR code in java and servlet.

Now here today we will learn how can we read QR Code in java.

Here again i had use same jar file as we had previuos. ZXing- Zibra Corossing

Here is code to read QR Code.


import java.io.FileInputStream;
import javax.imageio.ImageIO;

import com.google.zxing.BinaryBitmap;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.Result;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.HybridBinarizer;

public class QRReader {

public static void main(String args[]){

Result result = null;
BinaryBitmap binaryBitmap;

try{

binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(ImageIO.read(new FileInputStream("D:/Generated_QR.PNG")))));
result = new MultiFormatReader().decode(binaryBitmap);
System.out.println("QR Code : "+result.getText());

}catch(Exception ex){
ex.printStackTrace();
}
}
}

 

Hope you like it. Cheers… 🙂

 

 

Advertisements

About Sanju
I am Software Programmer. I am working in JAVA/J2EE Technologies.

One Response to Read QRCode in JAVA

  1. sainath says:

    thanku very much sir.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: