This site permanently moved to
https://droidscript.github.io
. Please update links accordingly.
You are being forwarded automatically in 3...
[stay here]
Back
ReadFile
Hello World
Reads a file from the local filesystem and returns its contents.
app.ReadFile(
file
,
encoding
)
See also:
WriteFile
Example - Append file and get line count
click to expand contents
function
OnStart
(
)
{
app
.
WriteFile
(
"myFile.txt"
,
"Hello World from Copy\n"
,
"Append"
)
;
var
txt
=
app
.
ReadFile
(
"myFile.txt"
)
;
var
length
=
txt
.
split
(
"\n"
)
.
length
;
app
.
ShowPopup
(
"myFile contains "
+
length
+
" lines"
)
;
}
Copy
Copy All
Run
String:
file path or content:// uri
String:
“US-ASCII”
or
“UTF-8”
or
“UTF-16”
or
“UTF-16BE”
or
“UTF-16LE”
or
“windows-1252”
or
“
ISO-8859-1
”
or
“base64”
loading