从文件中读取下一行内容。
getline()
示例
逐行读取文件直至结束。
javascript function main() { let file = os.open("data.txt", "r") let lineCount = 0 while (!file.eof()) { let line = file.getline() if (line) { lineCount++ Log("Line", lineCount + ":", line) } } Log("Total lines:", lineCount) file.close() }
返回值
string / undefined
返回下一行内容,到达文件末尾时返回undefined。
undefined
参考
close puts printf flush tell seek eof read write getline toString
close
puts
printf
flush
tell
seek
eof
read
write
getline
toString
备注
按行顺序读取文件内容。