Java String Split by Delimiter splitStringUsingDelimiter(String name, String delimiter)

Here you can find the source of splitStringUsingDelimiter(String name, String delimiter)

Description

split String Using Delimiter

License

Apache License

Declaration

public static String splitStringUsingDelimiter(String name, String delimiter) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Iterator;
import java.util.List;

public class Main {
    public static String splitStringUsingDelimiter(String name, String delimiter) {
        return splitStringUsingDelimiter(name, delimiter, false);
    }/*  w ww . j  ava2  s. co  m*/

    public static String splitStringUsingDelimiter(String name, String delimiter, boolean capped) {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < name.length(); i++) {
            char charAt = name.charAt(i);
            boolean delimiterAdded = false;
            if (i > 0 && Character.isUpperCase(charAt)) {
                buf.append(delimiter);
                delimiterAdded = true;
            }
            if (capped && (i == 0 || delimiterAdded))
                buf.append(Character.toUpperCase(charAt));
            else
                buf.append(Character.toLowerCase(charAt));
        }
        return buf.toString();
    }

    public static String toString(List<String> list, String delimiter) {
        String argumentString = "";
        Iterator<String> iterator2 = list.iterator();
        for (int i = 0; iterator2.hasNext(); i++) {
            String argument = iterator2.next();
            if (i > 0)
                argumentString += delimiter;
            argumentString += argument;
        }
        return argumentString;
    }
}

Related

  1. splitString(String str, String delim)
  2. splitString(String str, String delimiter)
  3. splitString(String str, String delims)
  4. splitString(String toSplit, String delimiter)
  5. splitStringList(String strList, String delimit)
  6. splitText(String text, String delimiter)
  7. splitToArray(String stringToSplit, String delimitter, boolean trim)
  8. splitToken(String str, String delimiter)
  9. splitToList(final String string, final String delim, final int limit)