//文件搜索,输出绝对路径
public void fileSearch(String fatherFile,String fileName){
if(fatherFile.contains("System Volume Information"))
return;
File father=new File(fatherFile);
String[] fileList=father.list();
for(int i=0;i<fileList.length;i++){
File middle=new File(fatherFile,fileList[i]);
if(middle.isFile()&&middle.getName().equals(fileName)){
System.out.println(middle.getAbsolutePath());
}
if(middle.isDirectory())
fileSearch(middle.getAbsolutePath(),fileName);
}
}
//*****************************************************************************
//按文件类型搜索,输出绝对路径
public void fileSearch(String fatherFile,String fileExtent){
if(fatherFile.contains("System Volume Information"))
return;
File father=new File(fatherFile);
String[] fileList=father.list();
for(int i=0;i<fileList.length;i++){
File middle=new File(fatherFile,fileList[i]);
if(middle.isFile()&&middle.getName().endsWith(fileExtent)){
System.out.println(middle.getAbsolutePath());
}
if(middle.isDirectory())
fileSearch(middle.getAbsolutePath(),fileExtent);
}
}
//*****************************************************************************
代码
//文件搜索,输出绝对路径
public void fileSearch(String fatherFile,String fileName){
if(fatherFile.contains("System Volume Information"))
return;
File father=new File(fatherFile);
String[] fileList=father.list();
for(int i=0;i<fileList.length;i++){
File middle=new File(fatherFile,fileList[i]);
if(middle.isFile()&&middle.getName().equals(fileName)){
System.out.println(middle.getAbsolutePath());
}
if(middle.isDirectory())
fileSearch(middle.getAbsolutePath(),fileName);
}
}
//*****************************************************************************
//按文件类型搜索,输出绝对路径
public void fileSearch(String fatherFile,String fileExtent){
if(fatherFile.contains("System Volume Information"))
return;
File father=new File(fatherFile);
String[] fileList=father.list();
for(int i=0;i<fileList.length;i++){
File middle=new File(fatherFile,fileList[i]);
if(middle.isFile()&&middle.getName().endsWith(fileExtent)){
System.out.println(middle.getAbsolutePath());
}
if(middle.isDirectory())
fileSearch(middle.getAbsolutePath(),fileExtent);
}
}
//*****************************************************************************