stream1 Node.js: 03. 파일 시스템 접근 1. fs Module fs 모듈은 파일 시스템에 접근하는 모듈이다. 파일 생성, 삭제 및 read/write 할 수 있다. 밑에 코드는 간단한 fs모듈을 사용한 코드이다. // 파일 시스템 접근 // fs모듈 : 파일 시스템에 접근 모듈 const fs = require('fs'); fs.readFile('./readme.txt', (err, data) => { if (err) { throw err; } console.log(data); console.log(data.toString()); }) 여기서 주의깊게 봐야할 것은 console.log(data) 의 출력값으로 버퍼가 나오는 것이다. 2. 버퍼와 스트림에서 자세히 설명하겠다. // writeFIle.js const fs = require('fs.. 2019. 9. 28. 이전 1 다음