Java XML Data Type Converter fromStringSafe(final String s)

Here you can find the source of fromStringSafe(final String s)

Description

from String Safe

License

Open Source License

Declaration

public static Object fromStringSafe(final String s) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayInputStream;

import java.io.IOException;
import java.io.ObjectInputStream;

import javax.xml.bind.DatatypeConverter;

public class Main {
    public static Object fromStringSafe(final String s) {
        try {//from www .  j  a  v a 2  s .  c  om
            return fromString(s);
        } catch (final Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    /** Read the object from Base64 string. */
    public static Object fromString(final String s) throws IOException, ClassNotFoundException {
        if (null == s) {
            return null;
        }
        final byte[] data = DatatypeConverter.parseBase64Binary(s);
        final ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data));
        final Object o = ois.readObject();
        ois.close();
        return o;
    }
}

Related

  1. encrypt(String plainText, String password)
  2. encryptPassword(String unencrypted)
  3. fetchUrl(String url, String username, String password)
  4. formatFriendlyName(final byte[] addressBytes)
  5. fromString(String s)
  6. generateSalt()
  7. generateSalt(int clientNonceByteCount)
  8. getByteList(String nomal, boolean isDecode)
  9. getByteListStr(List byteList, boolean isEncode)