未分类题
请完成下列Java程序。程序的功能是显示用户在命令行方式下指定的任意驱动器目录的内容。
.jpg)
(提示:public String[]list();//将目录中所有文件名保存在字符数组中返回)
注意:请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。
import java.io.*;
public class FindDirectories
{
public static void main(String args[]
{
if(args.length==0)
args=new String[]{'..'};
try
{
_______________
String[] fileName=pathName.list();
for(int i=0;i<fileName.length;i++
{
File f=new File(pathName.getPath() fileName[i]);
if(___________________)
{
System.out.println(f.getCanonicalPath());
main(new String[]
{
f.getPath()
});
}
}
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
A.shangxueba.cn/images/ct_ctjjm_simpapp_00092(20092).jpg'
B.io.*;
C.length==0)
D..'};
E.list();
F.length;i++
G.getPath()
H.out.println(f.getCanonicalPath());
I.getPath()
J.printStackTrace();
【参考答案】
File pathName=new File(args[0]); f.isDirectory()
File pa......
(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)