Skip to main content

readFileSync

function Deno.readFileSync
allow-read
Jump to headingreadFileSync(path: string | URL): Uint8Array

Synchronously reads and returns the entire contents of a file as an array of bytes. TextDecoder can be used to transform the bytes to string if required. Reading a directory returns an empty data array.

const decoder = new TextDecoder("utf-8");
const data = Deno.readFileSync("hello.txt");
console.log(decoder.decode(data));

Requires allow-read permission.

Parameters Jump to heading

Jump to headingpath: string | URL

Return Type Jump to heading

Uint8Array
Back to top