/**
* 图片转化成base64字符串
* @return
*/
public static String GetImageStr(String imgFileUrl) {// 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
InputStream in = null;
byte[] data = null;
// 读取图片字节数组
try {
in = new FileInputStream(imgFileUrl);
data = new byte[in.available()];
in.read(data);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
// 对字节数组Base64编码
BASE64Decoder decoder = new BASE64Decoder();
return encoder =encoder.encode(data);
换成下面的方法就可以啦!拿到别的项目都可以解析了
Base64 encoder = new Base64();
return encoder.encodeBase64String(data);// 返回Base64编码过的字节数组字符串
}