package ru.job4j.chat;

import java.io.*;
import java.util.List;
import java.util.Arrays;

public class FileDelimiterReader {
    private final File file;
    private final String delimiter;

    public FileDelimiterReader(File file, String delimiter) {
        this.file = file;
        this.delimiter = delimiter;
    }

    public List<String> getStrings() throws IOException {
        StringBuilder builder = new StringBuilder();
        try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
            String line;
            while ((line = reader.readLine()) != null) {
                builder.append(line);
            }
        }
        return Arrays.asList(builder.toString().split(delimiter));
    }
}
