Read file javascript

71 views
Skip to first unread message

Kallikratidas

unread,
Apr 6, 2019, 4:00:09 PM4/6/19
to DroidScript
How can I read data from a file with the File object?

When I call the new File(………)
or new FileReader(………)

I get an error.

Even though, I would like to know how to read a file with file Reader, because I know how to open a file object with it, not a specific url or path.

Rodwell

unread,
Jul 6, 2019, 11:39:33 AM7/6/19
to DroidScript
Hi,
The file reader is not complicated, you need to specify the file encoding in the options.

Example
//var txt = app.ReadFile( "sdcard/DroidScript/MyApp/MyApp.js", "UTF-8" );
//app.Alert( txt );

John

unread,
Jul 6, 2019, 10:42:38 PM7/6/19
to DroidScript
Are we talking 'app.ReadFile' or the 'ReadText' method of the File object? Two different things, with two very different reasons for using them.

Symbroson

unread,
Jul 7, 2019, 4:43:45 AM7/7/19
to DroidScript
@John Kallikratidas tried to use the JavaScript File or FileReader object. They don't work on a local filesystem. The DroidScript File object is a third different thing

John

unread,
Jul 7, 2019, 10:39:39 AM7/7/19
to DroidScript

Syed Munawer Hassan

unread,
Jul 20, 2019, 6:42:35 AM7/20/19
to DroidScript
use app.loadscript function
Reply all
Reply to author
Forward
0 new messages