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

前端 未结 6 1264
深忆病人
深忆病人 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:39

    This will work for small files, not for humongous files like say firewall or webserver log files.

    Those files won't load completely into memory at all.

    Is there a solution to 1/ read a file until you encounter the end of line char, 2/ process that which is read, 3/ and then continue until the next end of line/end of file char ?

    I think it would be possible using filestream reading 1 byte at a time and seeing if it contains a newline char, and pushing that byte content onto an array until you encounter the EOL char, but I'm not (yet) strong enough in AS to write something like that without loosing 3 months of my life... plus I'm not too sure about the speed of the process.

    Anyone ? I would prefer to not launch a seperate question as this essentially the same demand but for larger files...

提交回复
热议问题