如何读取txt文件中的行数?
我知道我必须使用 ByteBuffer 但我不知道如何使用它。
Dart 中有 scanf
吗?
最佳答案
var myFile = new File('file.txt');
// assuming a utf8 encoding
var numberOfLines = myFile.readAsLinesSync().length;
参见readAsLinesSync doc 提供其他编码。
关于dart - 如何在 Dart 中有效地获取文件中的行数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58171625/