这是我认为可行的概念,但由于某种原因,每次运行此代码时,我都会NullPointerException
在代码中得到一个:
for(String s : namesOfDirectoryFiles){
代码
public class poc {
private File current;
private File last;
private String[] namesOfDirectoryFiles;
private static Scanner input = new Scanner(System.in);
public static void main(String[] args){
poc p = new poc();
p.open("C:/");
p.open(input.nextLine());
}
private void open(String name){
current = new File(last, name);
namesOfDirectoryFiles = current.list();
for(String s : namesOfDirectoryFiles){
System.out.println(s);
}
}
}