我们如何才能只读取文件的选定部分?
像这样:Read(file, start, length)
您可以使用:file.position/2 http://erlang.org/doc/man/file.html#position-2 and :file.read/2 http://erlang.org/doc/man/file.html#read-2.
With:
$ seq 10 > 10.txt
和代码:
{:ok, file} = :file.open("10.txt", [:read, :binary])
:file.position(file, 5)
IO.inspect :file.read(file, 10)
输出是:
{:ok, "\n4\n5\n6\n7\n8"}
即从第 6 个字节开始的 10 个字节。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)