How to list the files in current directory?

前端 未结 7 2136
傲寒
傲寒 2021-02-05 01:05

I want to be able to list the files in the current directory. I\'ve made something that should work but doesn\'t return all the file names.

File dir = new File(\         


        
7条回答
  •  名媛妹妹
    2021-02-05 01:25

    Maybe the dot notation for current folder is incorrect?

    Print the result of File.getCanonicalFile() to check the path.

    Can anyone explain to me why src isn't the current folder?

    Your IDE is setting the class-path when invoking the JVM.

    E.G. (reaches for Netbeans) If you select menus File | Project Properties (all classes) you might see something similar to:

    Netbeans project options

    It is the Working Directory that is of interest here.

提交回复
热议问题