All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.jiangzeyin.util.StringUtil Maven / Gradle / Ivy

There is a newer version: 1.2.11
Show newest version
package cn.jiangzeyin.util;

import java.util.StringTokenizer;

/**
 * Created by jiangzeyin on 2017/8/14.
 */
public class StringUtil {
    private final static String CONFIG_LOCATION_DELIMITERS = ",; \t\n";

    public static String[] stringToArray(String str) {
        return stringToArray(str, CONFIG_LOCATION_DELIMITERS);
    }

    public static String[] stringToArray(String str, String separator) {
        if ((str == null) || (separator == null)) {
            return null;
        }

        int i = 0;
        StringTokenizer st = new StringTokenizer(str, separator);
        String[] array = new String[st.countTokens()];
        while (st.hasMoreTokens()) {
            array[(i++)] = st.nextToken();
        }
        return array;
    }
    public static String convertNULL(String input) {
        if (input == null)
            return "";
        return input.trim().intern();
    }

    public static String convertNULL(Object input) {
        if (input == null)
            return "";
        return convertNULL(input.toString());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy