private static int findEndQuote(final String line, final int startPos) {
        final char quoteChar = line.charAt(startPos);
        boolean quoted = true;

        for (int i = startPos + 1; i < line.length(); i++) {
            final char chr = line.charAt(i);

            if (chr == quoteChar) {
                if (i > 0 && line.charAt(i - 1) != '\\' || i == 0) {
                    quoted = !quoted;

                    if (!quoted && (i + 1 == line.length()
                            || line.charAt(i + 1) == ',')) {
                        return i;
                    }
                }
            }
        }

        throw new RuntimeException(MessageFormat.format(
                "End quote was not found on line: {0}", line));
    }