Java Utililty Methods String Split

List of utility methods to do String Split

Description

The list of methods to do String Split are organized into topic(s).

Method

String[]splitArguments(String s)
split Arguments
if (s == null || s.trim().length() == 0) {
    return new String[0];
s = s.trim();
List list = new ArrayList();
int lastIndex = 0;
int index = 0;
int length = s.length();
...
ListsplitArguments(String str)
split Arguments
List<String> list = new ArrayList<>();
splitArguments(str, list);
return list;
String[]splitArguments(String string)
Splits specified string in a manner which is similar to what is done for command line arguments.
ArrayList<String> list = new ArrayList<String>();
char quote = 0;
StringBuilder arg = null;
final int length = string.length();
for (int i = 0; i < length; ++i) {
    char c = string.charAt(i);
    if (Character.isWhitespace(c)) {
        if (quote != 0) {
...
String[]splitArguments(String string)
Split command line into arguments.
assert string != null;
ArrayList<String> result = new ArrayList<String>();
boolean escape = false;
boolean inString = false;
StringBuilder token = new StringBuilder();
for (int i = 0; i < string.length(); ++i) {
    char c = string.charAt(i);
    if (c == '"' && !escape) {
...
ListsplitArray(byte[] src, int size)
Splits an array into a list of smaller arrays with the maximum size of size.
int nChunks = src.length / size;
List<byte[]> chunkList = new ArrayList<byte[]>(nChunks + 1);
if (size >= src.length) {
    chunkList.add(src);
    return chunkList;
for (int i = 0; i < nChunks; i++) {
    byte[] chunk = new byte[size];
...
String[]splitArray(String[] srcArr, int start, int end)
split Array
List<Object> result = new ArrayList<Object>();
if (start < 0) {
    throw new ArrayIndexOutOfBoundsException();
end = end > srcArr.length ? srcArr.length : end;
for (int i = start; i < end; i++) {
    result.add(srcArr[i]);
return result.toArray(new String[0]);
ArrayListsplitAt(final String input, final String seperator)
Split a string at a separator and return the unique trimmed entries from the string.
final String[] parts = input.split(seperator);
final ArrayList<String> result = new ArrayList<String>();
for (final String part : parts) {
    final String partTrimmed = part.trim();
    if (!partTrimmed.equals("")) {
        result.add(partTrimmed);
return result;
ListsplitAtLastBlank(String s, int width)
Splits the specified string at the last blank before width.
List<String> chunks = new ArrayList<>();
String tmp = s;
while (tmp.length() > 0) {
    int index = findSplitpoint(tmp, width);
    chunks.add(tmp.substring(0, index));
    while (index < tmp.length() && tmp.charAt(index) == ' ') {
        index += 1;
    if (index < tmp.length() && tmp.regionMatches(index, NEWLINE, 0, NEWLINE.length())) {
        index += NEWLINE.length();
    if (index >= tmp.length()) {
        break;
    tmp = tmp.substring(index);
return chunks;
String[]splitAttributes(final String dname)

Separa las distintas partes, separadas por comas, de las que se compone el String proporcionado.

List<String> results = new ArrayList<String>();
String[] col = dname.split(",");
for (int i = 0; i < col.length; i++) {
    String piece = col[i];
    while (i < col.length - 1) {
        if (!col[i + 1].contains("=")) {
            piece += "," + col[++i];
        } else {
...
ArrayListsplitAuthors(String source)
split Authors
ArrayList<String> authors = new ArrayList<String>();
int idx = source.indexOf("_and_");
if (idx > -1) {
    String[] fields = source.split("_and_");
    for (int i = 0; i < fields.length; i++) {
        String field = cleanAuthor(fields[i]);
        if (i > 0) {
            field = "author:" + field;
...