This language bar is your friend. Select your favorite languages!

Idiom #197 Get a list of lines from a file

Retrieve the contents of file at path into a list of strings lines, in which each element is a line of the file.

using System.IO;
using System.Collections.Generic;
using System.Linq;
        public List<string> GetLines(string _path)
        {
            return File.ReadAllLines(_path).ToList();
        }
import fs from "fs";
fs.readFileSync(path).split("\n")
import java.io.File;
import java.nio.file.Files;
List<String> lines = Files.readAllLines(new File(path).toPath());
$lines = file($path);
if ($lines === false)
  die("Can't open file $path");
Classes
var
  Lines: TStringList;
...
  Lines := TStringList.Create;
  Lines.LoadFromFile(Path);
use Path::Tiny qw(path);
my @lines = path($path)->lines;
with open(path) as f:
    lines = f.readlines()
lines = open(path).readlines
Dim lines = IO.File.ReadAllLines(path).ToList

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

Jadiker