Here you can find the source of splitAtCommaOrPipe(String input)
public static String[] splitAtCommaOrPipe(String input)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; public class Main { public static String[] splitAtCommaOrPipe(String input) { ArrayList<String> result = new ArrayList<String>(); char character = '\0'; char previousCharacter; StringBuilder value = new StringBuilder(); for (int i = 0; i < input.length(); i++) { previousCharacter = character; character = input.charAt(i); if (character == ',' || character == '|') { if (previousCharacter == '\\') { value.setCharAt(value.length() - 1, character); continue; }//from w ww. j av a2 s . c om result.add(value.toString().trim()); value = new StringBuilder(); continue; } value.append(character); } result.add(value.toString().trim()); return result.toArray(new String[] {}); } }