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

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

    hmmm, it's really a bit strange to use space as a separator. I mean, you could do it this way:

    var result:Array = [];
    for each (var s:String in source.split(" ")) {
         var a:Array = s.split("=");
         result[a[0]] = a[1];
    }
    

    yet relying on " " for splitting, really is not such a good idea, can't you use JSON, CSV or XML?

提交回复
热议问题