相当于扫码二维码获取里面对应的信息。。。
https://blog.csdn.net/kangcool_sn/article/details/85096386
package utils;
import jp.sourceforge.qrcode.QRCodeDecoder;
import jp.sourceforge.qrcode.exception.DecodingFailedException;
import sun.misc.BASE64Decoder;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
/**
* Created by kzx on 2016-11-22.
*/
public class Base64ToQrcode {
/**
* 解析二维码(QRCode)
*
* @param imgPath 图片路径
* @return
*/
public String decoderQRCode(String imgPath) {
// QRCode 二维码图片的文件
File imageFile = new File(imgPath);
BufferedImage bufImg = null;
String content = null;
try {
bufImg = ImageIO.read(imageFile);
QRCodeDecoder decoder = new QRCodeDecoder();
content = new String(decoder.decode(new TwoDimensionCodeImage(bufImg)), "utf-8");
} catch (IOException e) {
System.out.println("Error: " + e.getMessage());
e.printStackTrace();
} catch (DecodingFailedException dfe) {
System.out.println("Error: " + dfe.getMessage());
dfe.printStackTrace();
}
return content;
}
/**
* 解析二维码(QRCode)
*
* @param base64字符串
* @return
*/
public String decoderQRCode2(String base64Str) {
BufferedImage bufImg = null;
String content = null;
try {
byte[] bytes =this.base64Stream(base64Str);
InputStream in_withcode = new ByteArrayInputStream(bytes);
bufImg = ImageIO.read(in_withcode);
QRCodeDecoder decoder = new QRCodeDecoder();
content = new String(decoder.decode(new TwoDimensionCodeImage(bufImg)), "utf-8");
} catch (IOException e) {
System.out.println("Error: " + e.getMessage());
e.printStackTrace();
} catch (DecodingFailedException dfe) {
System.out.println("Error: " + dfe.getMessage());
dfe.printStackTrace();
}
return content;
}
public byte[] base64Stream(String imgStr){
BASE64Decoder decoder = new BASE64Decoder();
byte[] bytes = null;
try {
// Base64解码
bytes = decoder.decodeBuffer(imgStr);
for (int i = 0; i < bytes.length; ++i) {
if (bytes[i] < 0) {// 调整异常数据
bytes[i] += 256;
}
}
}catch(Exception e){
}
return bytes;
}
public static void main(String[] args) {
String str="iVBORw0KGgoAAAANSUhEUgAAAJQAAACUCAIAAAD6XpeDAAADA0lEQVR42u3aW3ICIRAF0Ox/02YDsaLDvQ06Zz4tMyCHFP3g56fwPBaeZ+955fN357Dyu9pjbXvgwYMH7yZ4jUVvIE3OcwVjdFx48ODBg3cZLzW5VybdCFIa465siMY6w4MHDx68c/FSeedk/treTPDgwYMH7zvx2tip4KWxOeDBgwcP3rl47cN8JUhpF8dTxeKP7yrAgwcP3hfjTQYLd/786AcSPHjwvhjvUX5SRedUgbgdBE0+8ODBgwfv+tp+YhN1ZXHbxeXR9YQHDx48eP+u52Tx94RgZGWhTwt24MGDBw9eBi92MWbTpaBULffoC1rw4MGDB+8yXuNATk26Df+JBXd48ODBg5fBaye/sUP7gOBlV4ADDx48ePDySfoJjdClAm4owJksTL80B3jw4MGDd7nv2A5YUot1QnFgMkmPJezw4MGDB+/yi9qJ7eThn9oE2xrU8ODBgwfv33c2Cr67gpp2gbjxnW23x+DBgwfvhniNgGUSfrLA3Q6yKv+F8ODBgwfvz2Zsu7A72fhNBU2TAdTSfxs8ePDgwRvDmywWNwrH7UCmXpiGBw8ePHhxvF0F2cmGZxum0lWABw8ePHjxfl5qoo0iQCURLmBv6yrAgwcPHrxji7OpDdFO0htze3ssePDgwYN3eazGwTuZ2DYuPrXxYmPBgwcPHrzLhelUMNJYiMnG8q7C9NPvwIMHDx68y+9MXZhJJf6pg32pyVkOQGLA8ODBgwcvgrer0doIEBobtD1W/QISPHjw4MGLJ92p4GWygZy6dFTvKsCDBw8evPgFpF3N0nZCvSvBj70THjx48OCNHdSTC5GaQ2ojThblX+qkw4MHDx689H2fpeZk+2/bi97erKNg8ODBg3dDvPakG5vghICrEXSMJuzw4MGDd3O8yQChsUBHdwAaY8GDBw8evKPw2sl+OxiZbNjGbo/BgwcPHrzteO3i9WSC3yh21yMoePDgwYMX/wGTgUAKsl0EqFyUggcPHjx42y8gNb7TCKzagclpxW548ODBuyHeL9xbl2J4ZXhhAAAAAElFTxSuQxCC";
Base64ToQrcode handler = new Base64ToQrcode();
try {
//InputStream in_withcode = new ByteArrayInputStream(str.getBytes("UTF-8"));
ByteArrayInputStream tInputStringStream = new ByteArrayInputStream(str.getBytes());
//byte[] bytes =handler.base64Stream(str);
//InputStream in_withcode = new ByteArrayInputStream(bytes);
String str1= handler.decoderQRCode2(str);
System.out.println(str1);
} catch (Exception e) {
e.printStackTrace();
}
}
}