Removed deprecated DataTypeConverter invocations
This commit is contained in:
parent
93f1aa83d3
commit
8040787233
1 changed files with 16 additions and 6 deletions
|
@ -33,7 +33,7 @@ import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import javax.xml.bind.DatatypeConverter;
|
import java.util.Base64;
|
||||||
|
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
@ -253,9 +253,9 @@ public final class ImageConverter {
|
||||||
buf.append(nl.item(i).getNodeValue());
|
buf.append(nl.item(i).getNodeValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//blob = Base64.decode(buf.toString());
|
blob = Base64.getDecoder().decode(buf.toString());
|
||||||
blob = DatatypeConverter.parseBase64Binary(buf.toString());
|
//blob = DatatypeConverter.parseBase64Binary(buf.toString());
|
||||||
// We may have seen this image before, return the recycled version
|
// We may have seen this image before, return the recycled version
|
||||||
String sId1 = createId(blob);
|
String sId1 = createId(blob);
|
||||||
if (recycledImages.containsKey(sId1)) {
|
if (recycledImages.containsKey(sId1)) {
|
||||||
return recycledImages.get(sId1);
|
return recycledImages.get(sId1);
|
||||||
|
@ -347,8 +347,18 @@ public final class ImageConverter {
|
||||||
// This would be surprising
|
// This would be surprising
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return DatatypeConverter.printHexBinary(md.digest(blob))
|
return bytesToHex(md.digest(blob)) + bytesToHex(Arrays.copyOf(blob, 10));
|
||||||
+DatatypeConverter.printHexBinary(Arrays.copyOf(blob, 10));
|
}
|
||||||
|
|
||||||
|
private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
|
||||||
|
public static String bytesToHex(byte[] bytes) {
|
||||||
|
char[] hexChars = new char[bytes.length * 2];
|
||||||
|
for (int j = 0; j < bytes.length; j++) {
|
||||||
|
int v = bytes[j] & 0xFF;
|
||||||
|
hexChars[j * 2] = HEX_ARRAY[v >>> 4];
|
||||||
|
hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
|
||||||
|
}
|
||||||
|
return new String(hexChars);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue