nodejs 파일 업데이트
파일 업데이트
파일 시스템 모듈에는 파일을 업데이트하는 방법이 있습니다.
fs.appendFile()fs.writeFile()
이 fs.appendFile()메서드는 지정된 파일의 끝에 지정된 내용을 추가합니다.
"This is my text."를 추가하십시오. 파일 "mynewfile1.txt"의 끝까지 :
var fs = require('fs');
fs.appendFile('mynewfile1.txt', ' This is my text.', function (err) {
if (err) throw err;
console.log('Updated!');
이 fs.writeFile()메서드는 지정된 파일 및 내용을 바꿉니다.
"mynewfile3.txt"파일 내용 바꾸기 :
var fs = require('fs');
fs.writeFile('mynewfile3.txt', 'This is my text', function (err) {
if (err) throw err;
console.log('Replaced!');
});
});
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기