获取文件夹下得所有文件,并按文件夹先,文件后的顺序排

/**
	 * 获取文件夹下得所有文件,并按文件夹先,文件后的顺序排
	 * @param file 文件夹
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	public static Comparable[] getChildFiles(File file){
		File[] directories = file.listFiles(new FileFilter() {
			@Override
			public boolean accept(File pathname) {
				return pathname.isDirectory();
			}
		});
		File[] childFiles = file.listFiles(new FileFilter() {
			@Override
			public boolean accept(File pathname) {
				return pathname.isFile();
			}
		});
		Comparable[] copyArray = Arrays.copyOf(directories, directories.length+childFiles.length);
		for(int i = 1;i<=childFiles.length;i++){
			copyArray[directories.length+i-1]=childFiles[i-1];
		}
		return copyArray;
	}

你可能感兴趣的:(获取文件夹下得所有文件,并按文件夹先,文件后的顺序排)