#454 Code Review of a String Search Method in a File

Companies:
Tochka Bank
Themes:
JavaIO & NIOCode Review

Perform a code review:

boolean containsStringInData(String csvFile, String str) throw IOException {

    BufferedReader reader = new BufferedReader(new FileReader(csvFile);
    ArrayList<String> list = new ArrayList();

    String line;
    while ((line = br.readLine()) != null) {
        list.add(line);
    }

    boolean result;
    for (String s : list) {
        if (s == str) {
            result = true;
        }
    }

    return result;
}

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in