package core.utils.io;

import core.utils.logs.Logger;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class IOFileReader
{
    public String read(String path)
    {
        try(BufferedReader reader = new BufferedReader(new FileReader(path)))
        {
            String line;

            StringBuilder body = new StringBuilder();
            while (true)
            {
                line = reader.readLine();

                //null означает конец файла:
                if (line == null)
                {
                    break;
                }

                body.append(line);
            }

            return body.toString();
        }
        catch (IOException exception)
        {
            Logger.error("Exception occurred while reading file " + path + " " + exception.getMessage());
        }

        return "Empty";
    }
}
