public class WordChange {
public static boolean GenerateImage(String imgStr, String savedImagePath) {
// 文件字节数组字符串数据为空
if (imgStr == null) {
return false;
}
BASE64Decoder decoder = new BASE64Decoder();
try {
// Base64解码
byte[] b = decoder.decodeBuffer(imgStr);
for (int i = 0; i < b.length; ++i) {
{// 调整异常数据
if (b[i] < 0) {
b[i] += 256;
}
}
}
OutputStream out = new FileOutputStream(savedImagePath);
out.write(b);
out.flush();
out.close();
return true;
} catch (Exception e) {
return false;
}
}
}