Read a file one line at a time in node.js?

前端 未结 29 1084
深忆病人
深忆病人 2020-11-22 04:33

I am trying to read a large file one line at a time. I found a question on Quora that dealt with the subject but I\'m missing some connections to make the whole thing fit to

29条回答
  •  抹茶落季
    2020-11-22 05:01

    Edit:

    Use a transform stream.


    With a BufferedReader you can read lines.

    new BufferedReader ("lorem ipsum", { encoding: "utf8" })
        .on ("error", function (error){
            console.log ("error: " + error);
        })
        .on ("line", function (line){
            console.log ("line: " + line);
        })
        .on ("end", function (){
            console.log ("EOF");
        })
        .read ();
    

提交回复
热议问题