filehandle.close()
- 返回: <Promise>
关闭文件描述符。
const fsPromises = require('fs').promises;
async function openAndClose() {
let filehandle;
try {
filehandle = await fsPromises.open('thefile.txt', 'r');
} finally {
if (filehandle !== undefined)
await filehandle.close();
}
}
- Returns: <Promise> A
Promise
that will be resolved once the underlying file descriptor is closed, or will be rejected if an error occurs while closing.
Closes the file descriptor.
const fsPromises = require('fs').promises;
async function openAndClose() {
let filehandle;
try {
filehandle = await fsPromises.open('thefile.txt', 'r');
} finally {
if (filehandle !== undefined)
await filehandle.close();
}
}