Scan QR Code in Java.

A QR code is kind of a barcode that can be read by a machine. It is an optical label used to recognize objects or disseminate some information. In some use cases, you might need to scan a QR code. In accordance with such scenarios, this article explains how to scan a QR code programmatically in Java.

Java API Configuration to Scan or Recognize QR Barcode

You can easily acces the Aspose.BarCode for Java API to process different kinds of barcodes including the QR Codes. Quickly install the API by downloading its JAR files the New Releases section or use the following Maven configurations in the pom.xml file of your application.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>http://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-barcode</artifactId>
    <version>22.8</version>
</dependency>

Scan QR Code in Java

You need to folow the steps below to scan a QR Code:

  1. Create an instance of the BarCodeReader class and specify the DecodeType value.
  2. Instantiate an object of BarCodeResult class.
  3. Scan the QR Code and get output text.

The code snippet below explains how to scan a QR Code in Java:

Scan QR Code from a Stream in Java

The following are the steps to read a QR code from a Stream in Java:

  1. Load the input file from a Stream and initiate an object of the BarcodeReader class.
  2. Set the DecodeType property to QR and create an instance of BarCodeResult class.
  3. Scan the QR Code and print scanned result.

The following code snippet elaborates how to scan a QR code from a stream programmatically in Java:

Get a Free License

You may request a free temporary license to evaluate the API without any restrictions.

Conclusion

In this article, you have leanred how to scan a QR Code programmatically in Java. Furthermore, please visit the documentation section if you are interested to explore various other capabilities and features of the API. In case you need to discuss any of your concerns, please feel free to write to us at the forum.

See Also