This article mainly introduces node. fs. description of the close method. This article introduces fs. for details about the close method, syntax, parameters, instances, and source code, refer
Method description:
Close the file asynchronously.
Syntax:
The Code is as follows:
Fs. close (fd, [callback (err)])
Because this method belongs to the fs module, we need to introduce the fs module (var fs = require ("fs") before use "))
Receiving parameters:
The file descriptor passed when the fd file is open.
Callback
Example:
The Code is as follows:
Var fs = require ('fs ');
Fs. open ('/path/demo1.txt', 'A', function (err, fd ){
If (err ){
Throw err;
}
Fs. futimes (fd, 1388648322,138 8648322, function (err ){
If (err ){
Throw err;
}
Console. log ('futimes complete ');
Fs. close (fd, function (){
Console. log ('done ');
});
});
});
Source code:
[Code]
Fs. close = function (fd, callback ){
Binding. close (fd, makeCallback (callback ));
};
[Code]