Java Utililty Methods XML Data Type Converter

List of utility methods to do XML Data Type Converter

Description

The list of methods to do XML Data Type Converter are organized into topic(s).

Method

ObjectfromString(String s)
Deserializes an object from the specified base64 encoded string.
try {
    return new ObjectInputStream(new ByteArrayInputStream(DatatypeConverter.parseBase64Binary(s)))
            .readObject();
} catch (Exception e) {
    throw new RuntimeException(e.toString(), e);
ObjectfromStringSafe(final String s)
from String Safe
try {
    return fromString(s);
} catch (final Exception e) {
    e.printStackTrace();
    return null;
StringgenerateSalt()
generate Salt
return random(32);
StringgenerateSalt(int clientNonceByteCount)
generate Salt
final byte[] salt = new byte[clientNonceByteCount];
randomGenerator.nextBytes(salt);
return DatatypeConverter.printHexBinary(salt).toLowerCase();
ListgetByteList(String nomal, boolean isDecode)
seed 128bit
List<byte[]> byteList = new ArrayList<byte[]>();
byte[] tempByte = null;
if (isDecode) {
    tempByte = DatatypeConverter.parseBase64Binary(nomal);
} else {
    tempByte = nomal.getBytes(CHARACTER_SET);
int needBlankLength = 0;
...
StringgetByteListStr(List byteList, boolean isEncode)
get Byte List Str
byte[] listByte = new byte[byteList.size() * 16];
for (int i = 0; i < byteList.size(); i++) {
    byte[] temp = (byte[]) byteList.get(i);
    for (int j = 0; j < temp.length; j++) {
        listByte[j + (16 * i)] = temp[j];
int blankCnt = 0;
...
StringgetDataUrlForBytes(final byte[] bytes)
get Data Url For Bytes
StringBuilder inlineURL = new StringBuilder("data:;base64,");
inlineURL.append(DatatypeConverter.printBase64Binary(bytes));
return inlineURL.toString();
StringgetImgurContent(String clientID, byte[] image)
get Imgur Content
String imageString = DatatypeConverter.printBase64Binary(image);
URL url = new URL("https://api.imgur.com/3/image");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
String data = URLEncoder.encode("image", "UTF-8") + "=" + URLEncoder.encode(imageString, "UTF-8");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization", "Client-ID " + clientID);
...
longgetLong(byte[] data)
get Long
if (data != null) {
    try {
        String dataTypeS = DatatypeConverter.printHexBinary(data);
        long dataType_num = Long.parseLong(dataTypeS, 16);
        return dataType_num;
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
return 0;
StringgetText(URL url, String user, String password)
get Text
final StringBuffer buffer = new StringBuffer();
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
String userpass = user + ":" + password;
String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes());
connection.setRequestProperty("Authorization", basicAuth);
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line = reader.readLine();
while (line != null) {
...