I had to create a directory named stuff and write the stream into a text file inside the "stuff" directory. but, because the code in NodeJs doesn't execute in a serial fashion, I m getting an error which says the directory doesn't exist. any help would be appreciated. the code is pasted below.
var http = require("http");
var fs = require("fs");
var readStream = fs.createReadStream(__dirname+"/readMe.txt","UTF-8");
var writeStream;
fs.mkdir("stuff",function(){
writeStream = fs.createWriteStream(__dirname+"/stuff/writeMe.txt");
});
readStream.on("data",function(chunk){
writeStream.write(chunk);
});
via The-Higgs-Boson
No comments:
Post a Comment