파일 만들기
파일 시스템 모듈에는 새 파일을 만드는 방법이 있습니다.
fs.appendFile()fs.open()fs.writeFile()
이 fs.appendFile()메서드는 지정된 내용을 파일에 추가합니다. 파일이 존재하지 않으면 파일이 생성됩니다.
appendFile () 메서드를 사용하여 새 파일을 만듭니다.
var fs = require('fs');
fs.appendFile('mynewfile1.txt', 'Hello content!', function (err) {
if (err) throw err;
console.log('Saved!');
});
이 fs.open()메서드는 두 번째 인수로 "플래그"를 사용하고, 플래그가 "쓰기"에 대해 "w"이면 지정된 파일이 쓰기 위해 열립니다. 파일이 없으면 빈 파일이 만들어집니다.
open () 메서드를 사용하여 비어있는 새 파일을 만듭니다.
var fs = require('fs');
fs.open('mynewfile2.txt', 'w', function (err, file) {
if (err) throw err;
console.log('Saved!');
});
이 fs.writeFile()메서드는 지정된 파일과 내용이있는 경우 해당 내용을 바꿉니다. 파일이 존재하지 않으면 지정된 내용을 포함하는 새 파일이 생성됩니다.
writeFile () 메서드를 사용하여 새 파일을 만듭니다.
var fs = require('fs');
fs.writeFile('mynewfile3.txt', 'Hello content!', function (err) {
if (err) throw err;
console.log('Saved!');
});
게시글 목록
| 번호 | 제목 |
|---|---|
| 16329 |
node.js
Node.js MongoDB 정렬
|
| 16328 |
node.js
정규 표현식으로 필터링
|
| 16327 |
node.js
환경설정 - dotenv
|
| 16326 |
node.js
Node.js MongoDB 쿼리
|
| 16325 | |
| 16324 |
node.js
nodejs MongoDB Find All
|
| 16323 |
node.js
Node.js MongoDB find
|
| 16322 |
node.js
node.js MongoDB _id Field
|
| 16321 |
node.js
node.js MongoDB 여러 문서 삽입
|
| 16320 |
node.js
Node.js MongoDB Insert
|
| 16319 |
node.js
Node.js MongoDB 컬렉션 만들기
|
| 16318 |
node.js
Node.js MongoDB 데이터베이스 생성
|
| 16317 |
node.js
Node.js MongoDB 설치
1
|
| 16316 |
node.js
Node.js 전자 메일 보내기
|
| 16315 |
node.js
Node.js 파일 업로드
|
| 16310 |
node.js
node.js 이벤트 모듈
|
| 16309 |
node.js
node.js NPM
|
| 16308 |
node.js
node.js 파일삭제, 파일 이름 바꾸기
|
| 16305 |
node.js
nodejs 기초문법 - 클래스
3
|
| 16304 |
node.js
nodejs 기초문법 - 조건문 반복문
|
| 16303 |
node.js
nodejs .기초문법 변수선언 , 함수선언
|
| 16302 |
node.js
nodejs 파일 업데이트
|
| 16301 |
node.js
nodejs 파일 만들기
현재글
|
| 16300 |
node.js
nodejs 파일 읽기
1
|
| 16299 |
node.js
Node.js 쿼리 문자열 읽기 , 쿼리 문자열 분할하기
|
| 16298 |
node.js
NOde.js HTTP 모듈
|
| 16297 |
node.js
Node.js 모듈
|
| 16295 |
node.js
nods.js 시작하기
|
| 16294 |
node.js
node.js 란 2번째
|
| 16293 |
node.js
Node.js란
1
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기