code: public static List<String> split(String input) {
          List<String> result = new ArrayList<>();
          StringBuilder cur = new StringBuilder();
          State state = State.START_FIELD;
  
          for (int i = 0; i < input.length(); i++) {
              char ch = input.charAt(i);
              switch (ch) {
                  case ',':
                      switch (state) {
                          case IN_QFIELD:
                              cur.append(',');
                              break;
                          default:
                              result.add(cur.toString());
                              cur.setLength(0);
                              state = State.START_FIELD;
                              break;
                      }
                      break;
                  case '"':
                      switch (state) {
                          case START_FIELD:
                              state = State.IN_QFIELD;
                              break;
                          case IN_QFIELD:
                              state = State.END_QFIELD;
                              break;
                          case IN_FIELD:
                              throw new CSVParseException("unexpected quote", input, i);
                          case END_QFIELD:
                              cur.append('"');
                              state = State.IN_QFIELD;
                              break;
                      }
                      break;
                  default:
                      switch (state) {
                          case START_FIELD:
                              state = State.IN_FIELD;
                              break;
                          case IN_FIELD:
                          case IN_QFIELD:
                              break;
                          case END_QFIELD:
                              throw new CSVParseException("extra character after quoted string",
                                                          input, i);
                      }
                      cur.append(ch);
                      break;
              }
          }
  
          if (state == State.IN_QFIELD) {
              throw new CSVParseException("unclosed quote", input, input.length());
          }
  
          result.add(cur.toString());
          return result;
      }
docs: Splits an input line into a list of strings, handling quoting.
  
  @param input the input line
  @return the resulting list of strings