Using Qrcode.jar to generate and parse two-dimensional code (MAVEN version)

Source: Internet
Author: User
Add Qrcode.jar to the MAVEN library

MVN install:install-file
-dgroupid= package name
-dartifactid= project name
-dversion= version number
-dpackaging=jar
The =jar file

is in Path 1, and there is a jar in the local D disk, for example: D:\QRCode.jar

2,cmd executes the mvn install command
format as:
mvn install:install-file- Dfile=<path-to-file>-dgroupid=<group-id>-dartifactid=<artifact-id>-Dversion=<version>- Dpackaging=<packaging>
Example:
mvn install:install-file-dfile=d:\qrcode.jar-dgroupid= Qrcode-dartifactid=qrcode-dversion=3.0-dpackaging=jar

3, add the following statement in Pom.xml
<dependency>< Groupid>qrcode</groupid><artifactid>qrcode</artifactid><version>3.0</version> </dependency>




using Qrcode.jar to generate and parse two-dimensional codes

Two-dimensional code, is a black-and-white plane geometry through the corresponding coding algorithm to record text, pictures, URLs and other information of the barcode picture. The following figure

Characteristics of two-dimensional codes:

1. High density coding, large information capacity

Can accommodate up to 1850 uppercase letters or 2,710 digits or 1108 bytes, or more than 500 Chinese characters, more than ordinary bar code information capacity about dozens of times times higher.

2. Wide range of Codes

The bar code can be the picture, sound, text, signature, fingerprint, such as digital information can be encoded, with bar code to express; can represent multiple languages, can represent image data.

3. Strong fault-tolerant ability, with error correction function

This makes two-dimensional barcode due to perforation, defaced and other causes of local damage, can be correctly read, damage area of up to 50% can still recover information.

4. High decoding reliability

It is much lower than the common bar code decoding error rate two out of 10,000, the BER does not exceed one out of 10,000.

5. Encryption measures may be introduced

Confidentiality, good security.

6. Low cost, easy production, durable

Because of these characteristics, two-dimensional code is now more and more popular, application is more and more widely (see Baidu Encyclopedia, Introduction is not the focus), so master how to develop two-dimensional code is very good knowledge reserves, so this blog will explain how to generate, parse two-dimensional code.

One, Java

Jar Package Required: Qrcode.jar

http://download.csdn.net/detail/he90227/7867043

Twodimensioncode class: Two-dimensional code operation core class[Java]  View plain copy package qrcode;      import java.awt.color;   Import  java.awt.Graphics2D;   import java.awt.image.bufferedimage;   import  java.io.file;   import java.io.ioexception;   import java.io.inputstream;    import java.io.outputstream;      import javax.imageio.imageio;      import jp.sourceforge.qrcode.qrcodedecoder;   import  jp.sourceforge.qrcode.exception.decodingfailedexception;      import  com.swetake.util.qrcode;      public class twodimensioncode {              /**       *  Generate two-dimensional code (qrcode) Pictures        *  @param  content  storage content         *  @param  imgPath  Picture Path       */       public void encoderqrcode ( String content, string imgpath)  {            this.encoderqrcode (content, imgpath,  "PNG",  7);       }               /**        *  Generate two-dimensional code (qrcode) picture        *  @param  content  Storage content        *  @param  output  Output flow        */        public void encoderqrcode (string content, outputstream  Output)  {           this.encoderqrcode (content,  output,  "PNG",  7);       }           &NBSP;&NBSP;&Nbsp; /**       *  Generate two-dimensional code (qrcode) picture        *   @param  content  Storage content        *  @param  imgPath  Image Path        *  @param  imgType  photo type        */   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.