nd4j-common/src/main/java/org/nd4j/util/StringUtils.java
public static String[] split(
            String str, char separator) {
        // String.split returns a single empty result for splitting the empty
        // string.
        if (str.isEmpty()) {
            return new String[]{""};
        }
        ArrayList<String> strList = new ArrayList<String>();
        int startIndex = 0;
        int nextIndex = 0;
        while ((nextIndex = str.indexOf(separator, startIndex)) != -1) {
            strList.add(str.substring(startIndex, nextIndex));
            startIndex = nextIndex + 1;
        }
        strList.add(str.substring(startIndex));
        // remove trailing empty split(s)
        int last = strList.size(); // last split
        while (--last>=0 && "".equals(strList.get(last))) {
            strList.remove(last);
        }
        return strList.toArray(new String[strList.size()]);
    }
public static String[] split(
            String str, char separator) {
        // String.split returns a single empty result for splitting the empty
        // string.
        if (str.isEmpty()) {
            return new String[]{""};
        }
        ArrayList<String> strList = new ArrayList<String>();
        int startIndex = 0;
        int nextIndex = 0;
        while ((nextIndex = str.indexOf(separator, startIndex)) != -1) {
            strList.add(str.substring(startIndex, nextIndex));
            startIndex = nextIndex + 1;
        }
        strList.add(str.substring(startIndex));
        // remove trailing empty split(s)
        int last = strList.size(); // last split
        while (--last>=0 && "".equals(strList.get(last))) {
            strList.remove(last);
        }
        return strList.toArray(new String[strList.size()]);
    }
public static String [ ] split ( String str , char separator ) { // String.split returns a single empty result for splitting the empty // string. if ( str . isEmpty ( ) ) { return new String [ ] { "" } ; } ArrayList < String > strList = new ArrayList < String > ( ) ; int startIndex = 0 ; int nextIndex = 0 ; while ( ( nextIndex = str . indexOf ( separator , startIndex ) ) != - 1 ) { strList . add ( str . substring ( startIndex , nextIndex ) ) ; startIndex = nextIndex + 1 ; } strList . add ( str . substring ( startIndex ) ) ; // remove trailing empty split(s) int last = strList . size ( ) ; // last split while ( -- last >= 0 && "" . equals ( strList . get ( last ) ) ) { strList . remove ( last ) ; } return strList . toArray ( new String [ strList . size ( ) ] ) ; }
Split a string using the given separator, with no escaping performed.
@param str a string to be split. Note that this may not be null.
@param separator a separator char
@return an array of strings
Split a string using the given separator with no escaping performed .