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

cn.lkk.web.util.StringUtil Maven / Gradle / Ivy

The newest version!
package cn.lkk.web.util;

import com.alibaba.fastjson.JSONArray;

/**
 * @author wangfujun
 * @date 2018/12/18
 */
public class StringUtil {

    public static String[] str2arr(String str) {
        String[] res;
        try {
            JSONArray arr = JSONArray.parseArray(str.trim());
            res = new String[arr.size()];
            for (int i = 0, size = arr.size(); i < size; i++) {
                res[i] = arr.getString(i);
            }
        } catch (Exception ex) {
            res = str.split(",");
        }

        return res;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy