Triggers: Difference between revisions

47 bytes removed ,  5 October 2016
m
no edit summary
mNo edit summary
mNo edit summary
Line 296: Line 296:


<source lang="javascript" line>
<source lang="javascript" line>
f= file("/sdcard/myfile.txt")
f = file("/sdcard/myfile.txt")
file.writeLine("one");                       
f.writeLine("one");                       
file.writeLine("two");
f.writeLine("two");
file.writeLine("three");
f.writeLine("three");
file.close();     
f.close();     
var a = file.readLines();
var a = f.readLines();
</source>
</source>


<ol>
<ol>
<li>Open myfile.txt file on the sdcard. If the file does not exist, it is created.</li>
<li>Open myfile.txt file on the sdcard. If the file does not exist, it is created.</li>
<li>Write the file into a string "one"</li>
<li>Write the string "one" as a line to the file</li>
</ol>
</ol>
<ol start="5">
<ol start="5">
<li>Close the file, only then saved the file.</li>
<li>Save and close the file</li>
<li>Read the file from all the rows, the result is an array of strings to a.</li>
<li>Read all the lines of the file into the array a</li>
</ol>
</ol>