试了下面的方法不行,
用jdom从xml文件中读出a.bmp的内容是String类型然后如下处理:
FileOutputStream out = new FileOutputStream("c:/a.bmp");
PrintStream p = new PrintStream( out );
p.write(fj1.getBytes());
p.close();
但是生成的文件打不开,不知道哪里破坏了
用jdom从xml文件中读出a.bmp的内容是String类型然后如下处理:
FileOutputStream out = new FileOutputStream("c:/a.bmp");
PrintStream p = new PrintStream( out );
p.write(fj1.getBytes());
p.close();
但是生成的文件打不开,不知道哪里破坏了
上网搜就有了!
我也有方法不过在家里!
int length = 0;
if (str.length() % 2 == 0)
length = str.length() / 2;
else
length = str.length() / 2 + 1;
byte[] result = new byte[length];
String s = "";
int j = 0;
for (int i = 0; i < str.length(); i += 2) {
if ((i + 2) < str.length()) {
s = str.substring(i, i + 2);
} else {
s = str.substring(i, str.length());
}
if (!s.equals("") && !s.equals("##")) {
byte b = new Integer(Integer.parseInt(s, 16)).byteValue();
result[j++] = b;
}
}
return result;
}