List of utility methods to do XML Data Type Converter
byte[] | convertToTwoBytes(int numberToConvert) Converts an integer to two bytes. byte[] numInBytes = new byte[2]; String s1 = Integer.toHexString(numberToConvert); if (s1.length() % 2 != 0) { s1 = "0" + s1; byte[] hexas = DatatypeConverter.parseHexBinary(s1); if (hexas.length == 1) { numInBytes[0] = 0; ... |
Map | createBasicAuthenticationProperty(final String username, final String password) Create HTTP Basic credentials to be used in HTTP get or post methods. Map<String, String> map = new TreeMap<String, String>(); try { String base64Binary = DatatypeConverter .printBase64Binary((username + ":" + password).getBytes("US-ASCII")); map.put("Authorization", "Basic " + base64Binary); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); return map; |
byte[] | decode(final CharSequence _text) Decodes given _text . return DatatypeConverter.parseBase64Binary(_text.toString());
|
String[] | decode(String auth) decode auth = auth.replaceFirst("[B|b]asic ", ""); byte[] decodedBytes = DatatypeConverter.parseBase64Binary(auth); if (decodedBytes == null || decodedBytes.length == 0) { return null; return new String(decodedBytes).split(":", 2); |
String | decode(String source) decode return new String(DatatypeConverter.parseHexBinary(source), Charset.forName("UTF-8")); |
String | decode(String string, boolean decode) decode return decode ? decode(string) : string;
|
String[] | decodeBasicAuth(String auth) decode Basic Auth String uap = auth.replaceFirst("[B|b]asic", ""); byte[] decodedBytes = DatatypeConverter.parseBase64Binary(uap); if (decodedBytes == null || decodedBytes.length == 0) { return null; } else { return new String(decodedBytes).split(":", 2); |
String | decodeJavaOpts(String encodedJavaOpts) Decode the JVM options 1. String javaOptsBase64 = encodedJavaOpts.replaceAll("^\"+", "").replaceAll("\\s+$", "").replace("=", "="); return new String(DatatypeConverter.parseBase64Binary(javaOptsBase64), Charset.forName("UTF-8")); |
double[] | decodeToDoubleArray(String encoded) decode To Double Array byte[] objBytes = DatatypeConverter.parseBase64Binary(encoded); ByteArrayInputStream bais = null; ObjectInputStream ois = null; try { bais = new ByteArrayInputStream(objBytes); ois = new ObjectInputStream(bais); int arrayLength = ois.readInt(); double result[] = new double[arrayLength]; ... |
String | decrypt(String encryptedText, String password) decrypt try { SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES"); SecretKey key = keyFactory.generateSecret(new PBEKeySpec(password.toCharArray())); Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES"); String enc = encryptedText.substring(ENCODE.length() + 12); byte[] salt = DatatypeConverter .parseBase64Binary(encryptedText.substring(ENCODE.length(), ENCODE.length() + 12)); pbeCipher.init(Cipher.DECRYPT_MODE, key, new PBEParameterSpec(salt, 20)); ... |