/** * Created by deepak gautam on 05-01-2017. */ // reading and eriting filevar fs=require('fs'); fs.writeFileSync("abc.txt","hello coderes lets build something new "); console.log(fs.readFileSync("abc.txt").toString()); // path module// path modules are mainly used for dealing with the path of any link// we can alot of things wit path var path=require('path'); var homepage="deepkagautam/desktop//mywebsite/index.html"; console.log(path.normalize(homepage));//deepkagautam\desktop\mywebsite\index.htmlconsole.log(path.dirname(homepage));//deepkagautam/desktop//mywebsiteconsole.log(path.extname(homepage));//.htmlconsole.log(path.basename(homepage));//index.html // inbuilt functions console.log(__filename);//C:\Users\deepak gautam\WebstormProjects\fnodejs\file_operations.jsconsole.log(__dirname);//C:\Users\deepak gautam\WebstormProjects\fnodejs
Thursday, 5 January 2017
file module and path module
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment