Skip to main content
Bun 将 stdout 暴露为一个具有 Bun.stdout 属性的 [BunFile]。这可以用作 Bun.write() 的目标。 此代码将文件写入 stdout,类似于 Unix 中的 cat 命令。
https://mintcdn.com/teemo/2s-4Z6VdGqiCeBNX/icons/typescript.svg?fit=max&auto=format&n=2s-4Z6VdGqiCeBNX&q=85&s=087b260066909db1cd3e9c7292bc34b2cat.ts
const path = "/path/to/file.txt";
const file = Bun.file(path);
await Bun.write(Bun.stdout, file);

请参阅 文档 > API > 文件 I/O 了解 Bun.write() 的完整文档。