수

nodejs 파일 업데이트

· 2019-01-11 (금) 18:28:16 · 2698

파일 업데이트

파일 시스템 모듈에는 파일을 업데이트하는 방법이 있습니다.

  • 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!');
});

});

|
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
PHP 19-06-24 조회 3,196
PHP 19-06-09 조회 3,813
MySQL 19-04-01 조회 4,871
jQuery 19-03-20 조회 4,257
node.js 19-02-12 조회 3,357
node.js 19-02-12 조회 3,091
node.js 19-02-12 조회 3,353
node.js 19-02-07 조회 3,329
node.js 19-02-07 조회 3,068
node.js 19-02-07 조회 3,215
node.js 19-02-04 조회 2,955
node.js 19-02-04 조회 2,929
node.js 19-02-04 조회 3,373
node.js 19-01-31 조회 2,482
node.js 19-01-31 조회 2,634
node.js 19-01-31 조회 3,109
node.js 19-01-28 조회 2,873
node.js 19-01-28 조회 2,956
node.js 19-01-28 조회 2,797
node.js 19-01-22 조회 3,127
node.js 19-01-22 조회 2,888
node.js 19-01-22 조회 3,312
node.js 19-01-16 조회 2,757
node.js
[node.js]
19-01-16 조회 2,654
node.js 19-01-16 조회 9,329
node.js 19-01-12 조회 4,407
node.js 19-01-12 조회 3,009
node.js 19-01-12 조회 3,156
node.js 19-01-11 조회 2,699
node.js 19-01-11 조회 4,055