上面方法也可以,我这种直接就可以得到名字,不需要先转化为File对象File file=new File("D:\\");String test[];test=file.list();for(int i=0;i{System.out.println(test[i]);}