The use of Java three-party---->zxing Framework

Source: Internet
Author: User
Tags java se

Today we are going to learn about the usage of zxing, which only covers the Java SE section.

The study of Zxing

If you use zxing in a Java SE environment, you need to add dependencies in Maven's pom.xml:

<Dependency>    <groupId>Com.google.zxing</groupId>    <Artifactid>Javase</Artifactid>    <version>3.3.0</version></Dependency>
First, according to the content to generate two-dimensional code
 Public void Encodenoreturn (String content) {    try  {        new File ("File/huhx.png"). Topath ();         New Multiformatwriter (). Encode (content, Barcodeformat.qr_code, +);        " PNG ", Path);     Catch (Exception e) {        e.printstacktrace ();    }}

Second, according to the QR code to read the content
 Public Static voidMain (string[] args) {File file=NewFile ("File/huhx.jpg"); BufferedImage BufferedImage=NULL; Try{bufferedimage=imageio.read (file); } Catch(IOException e) {e.printstacktrace (); } Luminancesource Source=NewBufferedimageluminancesource (BufferedImage); Binarybitmap Bitmap=NewBinarybitmap (NewHybridbinarizer (source)); Hashtable<decodehinttype, string> hints =NewHashtable<decodehinttype, string>(); Hints.put (Decodehinttype.character_set,"GBK"); Result result=NULL; Try{result=NewMultiformatreader (). Decode (bitmap, hints); } Catch(notfoundexception e) {e.printstacktrace (); } String URL=Result.gettext (); System.out.println (URL);}

Friendship Link
    • Zxing's github address: https://zxing.github.io/zxing/

The use of Java three-party---->zxing Framework

Related Article

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.