**This is an old revision of the document!**

  • 一个数字值,例如10
    从IO流读取n个字节(以二进制模式)或字符(以文本模式),结果将以字符串形式返回。参见io.open以获取有关如何以不同模式打开文件的更多信息。
    `local chars = b:read(10)`  

    * “*n” 或 “*number”
    从IO流中读取下一组可被解释为数字的字节。请注意读取到的数字会受到打开模式为二进制还是文本的影响。参见io.open以获取有关如何以不同模式打开文件的更多信息。

    `local number = b:read("*n")`  

    * “*l”或者“*line”
    从IO流中读取下一行,截掉换行标记(可能是 \n,、\r或\r\n)。

    `local line = b:read("*l")`  

    * “*L”或者“*Line”
    从IO流中读取下一行,类似“line”,但是在结果中保留换行标记。
    local whole_line = b:read("*L")
    * “*a”或者“*all”
    从IO流中读取所有剩余内容,直到遇到nil。在此读取格式后再指定其他格式没有意义。
    local the_whole_file = b:read("*a")