String Builder vs Lists

前端 未结 5 1939
野的像风
野的像风 2021-01-17 01:19

I am reading in multiple files in with millions of lines and I am creating a list of all line numbers that have a specific issue. For example if a specific field is left bla

5条回答
  •  臣服心动
    2021-01-17 01:38

    Depends on how you can / want to break the code up.

    Given you are reading it in line order, not sure you need a list at all. Your current desired output implies that you can't output anything until the file is completely scanned. The size of the file suggests a one pass`analysis phase would be a good idea as well, given you are going to use buffered input as opposed to reading the entire thing into memory.

    I'd be tempted with an enum to describe the issue e.g Field??? is blank and then use that as the key a dictionary of string builders.

    As a first thought anyway

提交回复
热议问题