Read file contents into an ArrayList

后端 未结 2 747
有刺的猬
有刺的猬 2021-01-23 07:09

On a previous project I was required to read file contents into an array. Now I have to do the same thing only I have to read the contents into an ArrayList. A few problems I

2条回答
  •  [愿得一人]
    2021-01-23 07:13

    Instead of assigning the line to array[i], simply do arrayList.add(line)

    If this is not homework, consider using some 3rd party utilities like apache-commons FileUtils.readLines(..) or guava Files.readLines(..)

提交回复
热议问题