在Haxe中,是否有任何跨语言方法从文件中读取行(适用于所有Haxe目标语言?)
这是我正在尝试实现的方法存根:
static function readLine(fileName, lineNumber){
//now how can I get this method to work with all Haxe target languages?
}
Run Code Online (Sandbox Code Playgroud)
有可能在Sys类中找到相关方法,但我还没有找到它.
小智 7
static function readLine(fileName, lineNumber) {
var fin = sys.io.File.read(fileName, false);
try {
for (i in 0...lineNumber)
fin.readLine();
var line = fin.readLine();
fin.close();
} catch (e:haxe.io.Eof) { return null; }
return line;
}
Run Code Online (Sandbox Code Playgroud)
http://haxe.org/api/sys/io/file是您正在寻找的.
http://haxe.org/doc/neko/fileio 举个例子.