/*****/Package COM. google. zxing; import Java. io. file; import Java. io. ioexception; import Java. util. hashtable; import COM. google. zxing. common. bitmatrix; import COM. google. zxing. common. hybridbinarizer;/***** @ author hwy **/public class testendecode {/*****/Public testendecode () {// todo auto-generated constructor stub}/*** @ Param ARGs */public static void main (string [] ARGs) {// todo auto-generated method stub} // code public void encode () {try {string STR = "CN: Male; COP: Company; ZW: Title "; // string Path = "D: // hwy.png"; hashtable hints = new hashtable (); hints. put (encodehinttype. character_set, "GBK"); bitmatrix bytematrix; bytematrix = new multiformatwriter (). encode (STR, barcodeformat. qr_code, 200,200); file = new file (PATH); // writetofile (bytematrix, "PNG", file);} catch (exception e) {e. printstacktrace () ;}// decodes public void decode () {try {reader = new multiformatreader (); string imgpath = "D: // hwy.png "; file file = new file (imgpath); bufferedimage image; try {image = ImageIO. read (File); If (image = NULL) {system. out. println ("cocould not decode image");} luminancesource source = new bufferedimageluminancesource (image); binarybitmap bitmap = new binarybitmap (New hybridbinarizer (source); Result result; hashtable hints = new hashtable (); hints. put (decodehinttype. character_set, "GBK"); Result = new multiformatreader (). decode (bitmap, hints); string resultstr = result. gettext (); system. out. println (resultstr);} catch (ioexception IOE) {system. out. println (IOE. tostring ();} catch (readerexception re) {system. out. println (Re. tostring () ;}} catch (exception ex ){}}}