Default charset assumes UTF-8
Review this Java that reads an uploaded CSV's bytes, parses the header row, and maps each declared column to its index.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 16 min
Mark a line and say what kind of problem it is.0 findings
1Map<String, Integer> headerIndex(byte[] csvBytes) {
2 String text = new String(csvBytes); // file is UTF-8
3 String firstLine = text.split("\n", 2)[0];
4 String[] cols = firstLine.split(",");
5 Map<String, Integer> index = new HashMap<>();
6 for (int i = 0; i < cols.length; i++) {
7 index.put(cols[i].trim(), i); // e.g. "Pr\u00e9nom" -> 0
8 }
9 return index;
10}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.