The counterpart to readable streams are writable streams. Standard output is a writable stream. In this video, learn how to create and use writeable streams.
- [Instructor] In the last lesson, we took a look … at creating readable file streams. … We've also been using writable streams too. … The process.stdout object is a writeable stream. … I'm going to go into the start folder and create a New File. … And, I will call this file, writeStream. … So, process.stdout is a writeable stream, … which means it has a write method. … And, we can use the write method … to write data to a writeable stream. … So, if I wrote hello … word/n we can actually take this file … and run it in the TERMINAL and type node writeStream … and we can see the data hello world … has been written to the TERMINAL. … So, we can actually use the exact same interface … to write a file. … First thing I'm going to do is include the fs module … by requiring it. … And, I can create writeable file streams … using the fs.create writeStream method. … And, the first argument here is … where we're going to write the file. … So, I'll do this in the assets folder /myFile.txt … and again the second argument …
- What is Node.js?
- Installing Node.js
- The global object
- Importing the core modules
- Creating custom events with the EventEmitter
- Reading, writing, and removing files
- Working with file streams
- Creating child processes with the exec and spawn functions
Skill Level Intermediate
Node.js: Real-Time Web with Socket.IOwith Emmanuel Henri1h 24m Intermediate
1. What Is Node.js?
2. Set Up Your Environnment
3. Node Globals
4. Node Modules
5. File System Basics
6. Files and Streams
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.