do lines <- readFile f; putStr lines
FILE *file;
size_t len=0;
char *lines;
assert(file=fopen(f,"rb"));
assert(lines=malloc(sizeof(char)));
while(!feof(file))
{
assert(lines=realloc(lines,(len+0x1000)*sizeof(char)));
len+=fread(lines,1,0x1000,file);
}
assert(lines=realloc(lines,len*sizeof(char)));
int err = 0;
int fd = 0;
void * ptr = NULL;
struct stat st;
if ((fd = open (f, O_RDONLY))
&& (err = fstat (fd, &st)) == 0
&& (ptr = mmap (NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0)) != -1) {
const char * lines = ptr;
puts (lines);
munmap (ptr, st.st_size);
close (fd);
}
std::string fromFile(std::string _f)
{
std::ifstream t(_f);
t.seekg(0, std::ios::end);
size_t size = t.tellg();
std::string buffer(size, ' ');
t.seekg(0);
t.read(&buffer[0], size);
}
string lines = File.ReadAllText(f);
string lines = cast(string) read(f, size_t.max);
var lines = new File(f).readAsStringSync();
{ok, Lines} = file:read_file(F).
program p
character(len=:),allocatable :: s
open(unit=10,file='myfile',access='stream')
inquire(10,size=i)
allocate(character(len=i) :: s)
read(10)(s(j:j),j=1,i)
write(*,*)s
end program p
b, err := os.ReadFile(f)
if err != nil {
// Handle error...
}
lines := string(b)
fs.readFile(f, (err, lines) => {
if (err) {
// Handle error...
}
// Work with `lines` here.
}
byte[] encoded = Files.readAllBytes(Paths.get(f));
String lines = new String(encoded, StandardCharsets.UTF_8);
File F = new File(f);
try (Scanner s = new Scanner(F)) {
s.useDelimiter("\\R");
String n = lineSeparator(),
lines = s.tokens()
.collect(joining(n));
}
(with-open-file (stream f)
(uiop:slurp-stream-string stream))
(defvar *lines*
(with-open-file (stream f)
(let ((contents (make-string (file-length stream))))
(read-sequence contents stream)
:return contents)))
lines = io.input(f):read('a')
NSString *lines=[NSString stringWithContentsOfFile:f encoding:e error:NULL];
$lines = file_get_contents('f');
if ($lines === false) {
// handle error...
}
var
_lines, _f: String;
SL: TStringList;
begin
SL := TStringList.Create;
SL.LoadFromFile(_f);
_lines := SL.Text;
SL.Free;
end;
open my $fh, '<', $f;
my $lines = do { local $/; <$fh> };
close $fh;
with open(f) as fo:
lines = fo.read()
let lines = fs::read_to_string(f).expect("Can't read file.");
let mut file = File::open(f)?;
let mut lines = String::new();
file.read_to_string(&mut lines)?;
val lines = Source.fromFile(filename).getLines().mkString("\n")
| lines |
lines := f asFilename readStream upToEnd.
Dim lines = IO.File.ReadAllText(f)