crackyourinterview.com


To improves our performance please Like Share Subscribe(Will boost us)

Node.js File System Part2
Question Posted on 01 Apr 2024Home >> Tutorial >> Node.js Tutorial >> Node.js File System Part2

Node.js File System Part2

Node.js File System (FS) Part 2


We will take some example to open file and do operation like read and write operation on file system.

Here we will create a JavaScript file which named as "main.js" which is having the below code to open the file input.txt create in previous chapter to read and write operations.
File: main.js


Open File Code

Now we open Node.js command prompt and run the main.js file as given below:-
node main.js



Open File Code output

Node.js File Information Method


Below is the syntax to run method to get file information.
fs.stat(path,callback)


Parameter explanation:
  • (1)Path:-This parameter is a string which is having file name which include a path.

  • (2)flags:-This is the callback function which gets two arguments (err, stats) where stats is an object of fs.Stats type.



Node.js fs.Stats class Methods

0
0

NoMethodDescription
1stats.isfile()This method will returns true if file type is of a simple file.
2stats.isdirectory()This method will returns true if file type is of a directory.
3stats.isblockdevice()This method will return true if file type is of a block device.
4stats.ischaracterdevice()This method will return true if file type is of a character device.
5stats.issymboliclink()This method will return true if file type is of a symbolic link.
6stats.isfifo()This method will retunr true if file type is of fifo.
7stats.issocket()This methos will retunr true if file type is of asocket.


.


Most Visited Questions:-

Deep Learning Questions Answers
Below are the different Deep Leaning Questions and answer a More...

Continuous Integration Questions Answers
Below are the 20 odd questions for CI or Continuous Integra More...

Derived relationships in Association Rule Mining are represented in the form of __________.
Derived relationships in Association Rule Mining are repres More...

What is Gulpjs and some multiple choice questions on Gulp
Gulpjs is an open source whihc helps in building Javascript More...

Microservices Architecture Questions Answers
Below are the different questions on Microservices Architec More...




Other Important Questions

Parts of Node.js

Install Node.js Linux

Node.js First Example

Node.js Globals

Node.js DNS






@2014-2022 Crackyourinterview (All rights reserved)
Privacy Policy - Disclaimer - Sitemap