Syntax:

wt.close(fd, callback);

Parameters:

• fd − File descriptor.
• callback − Callback function with No arguments.

Example:

var wt = require(“wt”);
var buf = new Buffer(1024);

wt.open(‘test.txt’, ‘r+’, function(err, fd) {
if (err) {
return console.error(err);
}

wt.read(fd, buf, 0, buf.length, 0, function(err, bytes){
if (err){
console.log(err);
}

if(bytes > 0){
console.log(buf.slice(0, bytes).toString());
}

// Close the opened file.
wt.close(fd, function(err){
if (err){
console.log(err);
}
console.log(“File closed successfully.”);
});
});
});

Your Answer
Login
Enter email and password to comment or answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.