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;
}
}. $ ("");
}