base64解码后转成图片到本地,转换完成后提示无法打开此文件

这是生成代码
if (!"".equals(GZZ.getValue())) {//base64解码
BASE64Decoder decoder = new BASE64Decoder();
b = decoder.decodeBuffer(GZZ.getValue());
String path = "D:\"+GZZBM.getValue()+"_"+"查控员工作证"+".jpg";
os = new FileOutputStream(path);
os.write(b);
os.flush();
os.close();
}

我是把一个xml转成excel,然后需要把xml中节点里的某些属性里的经过base64编码后的内容转成图片,那些经过base64编码字符串的就是图片的二进制数组,不是其他,求大神,在线等。。。
图片是生成了,可是,打不开,如图
这就是生成后的图片

http://blog.csdn.net/a9529lty/article/details/6563499

求大神解答啊啊啊啊。。。。。

public void buildFilePdf(String finalPath, String content) throws Exception {
byte[] data = null;
data = content.getBytes();
String imgStr = new String(data);
BASE64Decoder decoder = new BASE64Decoder();
byte[] b = decoder.decodeBuffer(imgStr);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {// 调整异常数据
b[i] += 256;
}
}
File f = new File(finalPath);
f.createNewFile();
FileOutputStream fOut = null;
fOut = new FileOutputStream(f);
fOut.write(b);
fOut.flush();
if(fOut!=null){
fOut.close();
}
}

你试试,我就这样做出来了

public void buildFile(String finalPath, String content) throws Exception {
byte[] data = null;
data = content.getBytes();
String imgStr = new String(data);
BASE64Decoder decoder = new BASE64Decoder();
byte[] b = decoder.decodeBuffer(imgStr);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {// 调整异常数据
b[i] += 256;
}
}
Bitmap bm = BitmapFactory.decodeByteArray(b, 0, b.length);
File f = new File(finalPath);
f.createNewFile();
FileOutputStream fOut = null;
fOut = new FileOutputStream(f);
bm.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
fOut.flush();
if(fOut!=null){
fOut.close();
}
}

刚才那个没有复制好手误

可以吗?我这边绝对可以

嗯,谢谢,我找到错误了, b = decoder.decodeBuffer(GZZ.getValue().replaceAll(" ", ""));这句话应该这么些,他又空格,要给他消掉