W3cubDocs

/Deno

Deno.readTextFileSync

Synchronously reads and returns the entire contents of a file as utf8 encoded string. Reading a directory throws an error.

const data = Deno.readTextFileSync("hello.txt");
console.log(data);

Requires allow-read permission.

function readTextFileSync(path: string | URL): string;
readTextFileSync(path: string | URL): string

Parameters

path: string | URL

Return Type

string