teach-matsuuratomoya-com/content/docs/2023/mediaart-programming2/5/load_text.js

9 lines
346 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//ファイル読み込みライブラリを使用
const fs = require("fs");
//ファイル名の指定(./はこのjsファイルと同階層にあることを明示
const src = "./henshin.txt";
//ファイルを読み込み
const bytes = fs.readFileSync(src);
//バイト列から文字列に
const txt = bytes.toString();
console.log(txt);