In Haxe, is there any cross-language method for reading lines from a file (that works with all Haxe target languages?)
Here's the method stub that I'm trying to implement:
static function readLine(fileName, lineNumber){
//now how can I get this method to work with all Haxe target languages?
}
It might be possible to find a relevant method in the Sys class, but I haven't yet found it.
解决方案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;
}