Reading the text file line by line and push to an array in AS3

前端 未结 6 1256
深忆病人
深忆病人 2020-12-16 19:05

I need some code in AS3 that will read a text file line by line and insert it into an array. Is this possible without having any special character?

sample.tx

6条回答
  •  旧巷少年郎
    2020-12-16 19:21

    For those wondering about large text files, you can't know when there'll be a line break before you read the line break byte. What I suggest is to have a loop that would instead of read all bytes with

    fileStream.readUTFBytes(fileStream.bytesAvailable);

    You do a few hundred bytes at a time, process whatever you need, then continue reading after.

提交回复
热议问题