(Andriod Firefox插件)需要从Data.txt中读取

时间:2017-04-05 23:20:48

标签: android firefox firefox-addon

我是android firefox插件的初学者。从路径(/ mnt / sdcard /)读取file.txt有些困难。我知道台式机是可能的,但我不知道这是否可能适用于Android。我花了两天时间,但它没有用。这是我的bootstrap.js代码

 var file = Components.classes["@mozilla.org/file/directory_service;1"].  
             getService(Components.interfaces.nsIProperties)
             .get("/mnt/sdcard/", Components.interfaces.nsIFile);  
 file.append("NewDir");  
if( !file.exists() || !file.isDirectory() ) {   

file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);  
}  
this.log_file=file.path+"/Data.txt";

var is = Components.classes["@mozilla.org/network/file-input-stream;1"]
        .createInstance( Components.interfaces.nsIFileInputStream );
is.init( file,0x01, 00004, null);
var is = Components.classes["@mozilla.org/network/file-input-stream;1"]
        .createInstance( Components.interfaces.nsIFileInputStream );
is.init( file,0x01, 00004, null);

var sis = Components.classes["@mozilla.org/scriptableinputstream;1"]
        .createInstance( Components.interfaces.nsIScriptableInputStream );
sis.init( is );
var output = sis.read( sis.available() );

代码不起作用

0 个答案:

没有答案