List<String> (@NotNull String command) { List<String> split = new ArrayList<>(); boolean insideParam = false; StringBuilder currentParam = new StringBuilder(); for (char c : command.toCharArray()) { boolean flush = false; if (insideParam) { if (c == '\'') { insideParam = false; flush = true; } else { currentParam.append(c); } } else if (c == '\'') { insideParam = true; } else if (c == ' ') { flush = true; } else { currentParam.append(c); } if (flush) { if (!StringUtil.isEmptyOrSpaces(currentParam.toString())) { split.add(currentParam.toString()); } currentParam = new StringBuilder(); } } // last flush if (!StringUtil.isEmptyOrSpaces(currentParam.toString())) { split.add(currentParam.toString()); } return split; }