Search code examples
apache-flextextsubstringflash-builder

Adobe Flash Builder read a text file and sort it by substring


In my Adobe Flash Builder project, I want to read a text file line-by-line, and get the number of each category (according to the value of a substring).

This my text file (MyTest.txt):

1988031,PROJECT,001.pdf,09012d9f80007111,09012d9f80007120
1988033,TEST,033.pdf,09012d9f80007921,09012d9f80007930
1988035,PROJECT,035.pdf,09012d9f80008db1,09012d9f80008dc0
1988036,PROJECT,036.pdf,09012d9f80008db2,09012d9f80008dc1

What I want to get:

  1. Substring 0 - Substring 4 for each line
  2. Number of lines which contains "PROJECT"

I found some solution for Adobe AIR, but I failed to find an answer for Flash.

I am stuck on how to process the text file.

How can get the result I want?


Solution

  • Use String.split() method to split the lines at commas.

    (If you have commas surrounded by white space - use regexes instead of split).

    Put split-results into objects and store them into an ArrayCollection.

    Then sort the ArrayCollection with spark.collections.Sort.