Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

copy text from file to another file in javascript with fs

'use strict';

import fs from 'fs';

let fileContent = 'Anything what you want';
let message = fs.writeFileSync('message.txt', fileContent);

function copyContent(fileName: string, dest: string): boolean {
  try {
    fs.copyFileSync(fileName, dest);
    console.log(dest);
    return true;
  } catch (err) {
    return false;
  }
}

console.log(copyContent('message.txt', 'destination.txt'));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #copy #text #file #file #javascript #fs
ADD COMMENT
Topic
Name
8+4 =