How to get contents of a folder and put into an ArrayList

后端 未结 5 1048
滥情空心
滥情空心 2020-12-14 06:10

I want to use

File f = new File(\"C:\\\\\");

to make an ArrayList with the contents of the folder.

I am not very good with buffered

5条回答
  •  甜味超标
    2020-12-14 06:38

    The easiest way of doing that is:

    File f = new File("C:\\");
    ArrayList files = new ArrayList(Arrays.asList(f.listFiles()));
    

    And if what you want is a list of names:

    File f = new File("C:\\");
    ArrayList names = new ArrayList(Arrays.asList(f.list()));
    

提交回复
热议问题