java 查询目录下所有的文件(包含递归)

java 查询目录下所有的文件(包含递归)_第1张图片


import java.io.File;


public class dd {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String path = "G://Image//つくもたん素材//";    
		getFile(path);  
		
	}

	   private static void getFile(String path){    
		        // get file list where the path has    
		        File file = new File(path);    
		           // get the folder list    
		           File[] array = file.listFiles();    
		              
		           for(int i=0;i<array.length;i++){    
		               if(array[i].isFile()){    
		                   // only take file name    
		                   System.out.println("|-->  " + array[i].getName());    
		                   // take file path and name    
		                   System.out.println("#####" + array[i]);    
		                   // take file path and name    
		                   System.out.println("*****" + array[i].getPath());    
		               }else if(array[i].isDirectory()){    
		                   getFile(array[i].getPath());    
		               }    
		           }    
		       }    
	}    

	

java 查询目录下所有的文件(包含递归)_第2张图片



你可能感兴趣的:(java 查询目录下所有的文件(包含递归))