jetbrick-commons/src/main/java/jetbrick/lang/StringUtils.java
public static String[] splitCSV(String str) {
        if (str == null) return null;
        String[] parts = StringUtils.split(str, ',');

        List<String> results = new ArrayList<String>();
        for (int i = 0; i < parts.length; i++) {
            String s = parts[i].trim();
            if (s.length() == 0) {
                results.add(s);
            } else {
                char c = s.charAt(0);
                if (c == '"' || c == '\'' || c == '`') {
                    StringBuilder sb = new StringBuilder();
                    sb.append(s);
                    while (i + 1 < parts.length) {
                        if (sb.length() > 1 && s.length() > 0 && s.charAt(s.length() - 1) == c) {
                            break;
                        }
                        s = parts[++i];
                        sb.append(',').append(s);
                    }
                    s = sb.toString().trim();
                    if (s.charAt(s.length() - 1) == c) {
                        s = s.substring(1, s.length() - 1);
                    }
                    results.add(s);
                } else {
                    results.add(s);
                }
            }
        }
        return results.toArray(new String[results.size()]);
    }
public static String[] splitCSV(String str) {
        if (str == null) return null;
        String[] parts = StringUtils.split(str, ',');

        List<String> results = new ArrayList<String>();
        for (int i = 0; i < parts.length; i++) {
            String s = parts[i].trim();
            if (s.length() == 0) {
                results.add(s);
            } else {
                char c = s.charAt(0);
                if (c == '"' || c == '\'' || c == '`') {
                    StringBuilder sb = new StringBuilder();
                    sb.append(s);
                    while (i + 1 < parts.length) {
                        if (sb.length() > 1 && s.length() > 0 && s.charAt(s.length() - 1) == c) {
                            break;
                        }
                        s = parts[++i];
                        sb.append(',').append(s);
                    }
                    s = sb.toString().trim();
                    if (s.charAt(s.length() - 1) == c) {
                        s = s.substring(1, s.length() - 1);
                    }
                    results.add(s);
                } else {
                    results.add(s);
                }
            }
        }
        return results.toArray(new String[results.size()]);
    }
public static String [ ] splitCSV ( String str ) { if ( str == null ) return null ; String [ ] parts = StringUtils . split ( str , ' ' ) ; List < String > results = new ArrayList < String > ( ) ; for ( int i = 0 ; i < parts . length ; i ++ ) { String s = parts [ i ] . trim ( ) ; if ( s . length ( ) == 0 ) { results . add ( s ) ; } else { char c = s . charAt ( 0 ) ; if ( c == ' ' || c == ' ' || c == ' ' ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( s ) ; while ( i + 1 < parts . length ) { if ( sb . length ( ) > 1 && s . length ( ) > 0 && s . charAt ( s . length ( ) - 1 ) == c ) { break ; } s = parts [ ++ i ] ; sb . append ( ' ' ) . append ( s ) ; } s = sb . toString ( ) . trim ( ) ; if ( s . charAt ( s . length ( ) - 1 ) == c ) { s = s . substring ( 1 , s . length ( ) - 1 ) ; } results . add ( s ) ; } else { results . add ( s ) ; } } } return results . toArray ( new String [ results . size ( ) ] ) ; }
按逗号分隔，两边加引号的不分割（CSV 规则）.
按逗号分隔，两边加引号的不分割（CSV 规则） .