Atitit. QR code generation summary java zxing

Source: Internet
Author: User

Atitit. QR code generation summary java zxing

# ----- Zxing class library ..
But zxing3.0 class library core-3.0.jar needs jdk7
So zing2.2.jar... jdk6 goes to OK ..


Author old wow's paw Attilax iron, EMAIL: 1466519819@qq.com
Reprinted please indicate Source: http://blog.csdn.net/attilax

# --- Qrcode. jsp


 
<%

Sharex c = new com. xx. share. sharex ();
String imgsrc = c. gene (request. getParameter ("oid "));

%>

 

# ----- Com. xx. share. sharex. java

Public String gene (String code ){
String qrcodedir = "qrcodeO5/" + filex. getuidname () + ". jpg ";

String path = pathx. webAppPath () + "/" + qrcodedir;
Filex. createAllPath (path );
Core. log ("-- qrcode path:" + path );
// Attilax old wow's paw 5:30:42 May 11, 2014
Qrcodex. gene (code, path, 250,250 );
Return qrcodedir;
}


# ---- Com. attilax. qrcode. qrcodex. javar


Public static void gene (final String content, final String path,
Final int width, final int height ){
New tryX <Object> (){

@ Override
Public Object item (Object t) throws Exception {
// Attilax old wow's paw 5:23:26 May 11, 2014
MultiFormatWriter multiFormatWriter = new MultiFormatWriter ();

Map hints = new HashMap ();
Hints. put (EncodeHintType. CHARACTER_SET, "UTF-8 ");

BitMatrix bitMatrix = multiFormatWriter. encode (content, BarcodeFormat. QR_CODE, width, height, hints );
File file1 = new File (path );
MatrixToImageWriter. writeToFile (bitMatrix, "jpg", file1 );
Return null;
}
}. $ ("");
}

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.