import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Base64;
public void createPhoto(String base64,String path){
try
{
//Base64解码
byte[] b = Base64.getDecoder().decode(base64);
for(int i=0;i<b.length;++i)
{
if(b[i]<0)
{//调整异常数据
b[i]+=256;
}
}
//生成jpeg图片
OutputStream out = new FileOutputStream(path);
out.write(b);
out.flush();
out.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args) {
String base64 = "base64字符串";
String patch = "D:\\das.jpeg";
CreatImage creatImage = new CreatImage();
creatImage.createPhoto(base64, patch);
}