How to copy a file in Node.js?
There are various methods used in Node.js such as readFile() and writeFile() method. The readFile() and writeFile() method is used to copy the content of the file to another file.
- file: Source filename path.
- option: It has to encode i.e. utf8.
- callback: The callback gets two arguments.
- filename: Filepath of the file to read.
- data: It is the data that we want to write.
- encoding: It is the encoding of the data.
- callback: It will show the error or null.
'File Reading from file.txt ..........'
'Content has been pasted to paste.txt file'