Java 备份BLOB类型的数据生成INSERT语句可识别的字符
做数据库备份得时候,备份二进制的数据类型如BLOB类型的数据
public static String hexToString() throws Exception {
try {
? ? ? ? ? ? ? ? ? ? ? ?InputStream in = rs.getBinaryStream(1);
int b;
StringBuffer result =new StringBuffer();
while ((b = in.read()) != -1) {
String hex = Integer.toHexString(b & 0xFF);
if (hex.length() == 1) {
hex = 0 + hex;
}
result.append(hex.toUpperCase());
}
return "0x"+result.toString();
} catch (Exception e) {
throw e;
}
}
?