- 檔案系統模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 系統模組
- PhantomJS - 屬性
- 網路伺服器模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 雜項
- 命令列介面
- PhantomJS - 螢幕截圖
- PhantomJS - 網頁自動化
- PhantomJS - 網路監控
- PhantomJS - 測試
- PhantomJS - REPL
- PhantomJS - 示例
- PhantomJS 實用資源
- PhantomJS - 快速指南
- PhantomJS - 實用資源
- PhantomJS - 討論
PhantomJS - 讀取
此方法讀取指定檔案中存在的資料。
語法
其語法如下 −
var fs = require('fs');
fs.read(path);
示例
我們來看一個示例,瞭解 **read** 方法如何工作。
命令 − phantomjs read.js test.txt
var fs = require('fs');
var system = require('system');
var path = system.args[1];
console.log(fs.read(path));
phantom.exit();
Test.txt 檔案
I am Testing Phantomjs
以上程式會生成以下 **輸出**。
I am Testing Phantomjs
phantomjs_file_system_module_methods.htm
廣告