Java String Split by Comma splitOnComma(String cs)

Here you can find the source of splitOnComma(String cs)

Description

split On Comma

License

Apache License

Declaration

static List<String> splitOnComma(String cs) 

Method Source Code


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

import java.util.List;
import java.util.ArrayList;

public class Main {
    static List<String> splitOnComma(String cs) {
        List<String> args = new ArrayList<String>();
        if (cs == null) {
            return args;
        } else {/*from w ww.  ja  v a2s . c  o  m*/
            String[] split = cs.split("(?<!\\\\),");
            for (String arg : split) {
                args.add(arg.trim().replaceAll("\\\\,", ","));
            }
            return args;
        }
    }
}

Related

  1. splitCommand(String command)
  2. splitCommandString(String command_string)
  3. splitCommaSequence(String argumentString)
  4. splitCommaStr(String commaStr)
  5. splitDoubleParentCommas(String input)
  6. splitWithCommaOrSemicolon(String src)