No, you can’t read or write files in JS on the client-side(browsers). You have to use node.js fs library (File-System) to manage all read and write operations on the server-side.
To write content to the file:
writeFile(Path, Data, Callback)
To read content to the file:
readFile(Path, Options, Callback)
Interested in Java? Check out this Java Certification by Intellipaat.