/*判断e盘的根目录是否含有.doc文件,如果有输出这些文件*/
public class File3Demo {
public static void main(String[] args) {
// TODO Auto-generated method stub
File file = new File("e:\\");
File[] fileArray = file.listFiles();
for(File f: fileArray){
if(f.isFile()){ //如果是文件
if(f.getName().endsWith(".docx")){ //如果文件已.doc结尾
System.out.println(f.getName()); //输出文件名
}
}
}
}
}
/*
运行结果:
思维.docx
思维与智慧.docx
研究工具.docx
研究生阶段目标.docx
职场.docx
*/
public class File3Demo {
public static void main(String[] args) {
// TODO Auto-generated method stub
File file = new File("e:\\");
File[] fileArray = file.listFiles();
for(File f: fileArray){
if(f.isFile()){ //如果是文件
if(f.getName().endsWith(".docx")){ //如果文件已.doc结尾
System.out.println(f.getName()); //输出文件名
}
}
}
}
}
/*
运行结果:
思维.docx
思维与智慧.docx
研究工具.docx
研究生阶段目标.docx
职场.docx
*/

2875

被折叠的 条评论
为什么被折叠?



