Review generated CSV row formatter

from Strings
Java 25 LTS advanced 6 min 5 issues to find

Review this generated CSV-row formatter.

Given a nonempty list of customer cells, reject blank cells, cap each value at maxCodePoints without splitting Unicode code points, escape CSV fields, preserve order, avoid logging, and return one row efficiently.

Java
import java.util.List;

class CsvRows {
    static String row(List<String> cells, int maxCodePoints) {
        String result = "";

        for (String raw : cells) {
            String cell = raw.trim();
            if (cell == "") continue;
            if (cell.length() > maxCodePoints) {
                cell = cell.substring(0, maxCodePoints);
            }

            if (cell.contains(",")) cell = "\"" + cell + "\"";
            System.out.println("adding " + cell);
            result += cell + ",";
        }

        return result.substring(0, result.length() - 1);
    }
}

generated code is illustrative, not from any one model

Open in playground
Report an error