Answers for "convert buffer to txt nodejs"

1

nodejs create buffer from string

// a string
const str = "Hey. this is a string!";

// convert string to Buffer
const buff = Buffer.from(str, "utf-8");

console.log(buff); // <Buffer 48 65 79 2e ... 72 69 6e 67 21>
Posted by: Guest on December-31-2021
-1

write buffer to file in node

fs = require('fs');
fs.writeFile('helloworld.txt', 'Hello World!', function (err) {
  if (err) return console.log(err);
  console.log('Hello World > helloworld.txt');
});
Posted by: Guest on April-19-2021

Code answers related to "convert buffer to txt nodejs"

Code answers related to "Javascript"

Browse Popular Code Answers by Language