Search the deepest folder or file ..
Search the deepest folder without the file which some like *.jar
deepest: without:*.jar
deepest: with:*.jar
How to search the deepest folder or files with everything?
Re: How to search the deepest folder or files with everythin
There is no option to search the deepest folders, you might be able to use the parents: macro.
The parents: macro allows you to specify the number of parents a file or folder must have.
For example, files and folders with more than 5 parents:
To exclude a search, prefix a !
For example, to exclude *.jar:
The parents: macro allows you to specify the number of parents a file or folder must have.
For example, files and folders with more than 5 parents:
Code: Select all
parents:>5
For example, to exclude *.jar:
Code: Select all
!*.jar
Re: How to search the deepest folder or files with everythin
implement by the java , myself
Code: Select all
package com.tan;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
/**
* @author qwop
*
*/
public class DeepestMain {
/**
* @param args
*/
public static void main(String[] args) {
File root = new File( System.getProperty( "user.home" ) +
File.separator + ".m2" +
File.separator + "repository"
);
final List<File> deepestFolders = new ArrayList<File>();
root.listFiles( new FileFilter() {
@Override
public boolean accept(File pathname) {
if ( pathname.isDirectory() ) {
pathname.listFiles( this );
if ( !hadChildFolder( pathname ) ) {
deepestFolders.add( pathname );
}
}
return false; // ignore the result.
}
});
System.out.println( deepestFolders.size() );
}
public static boolean hadChildFolder( final File folder ) {
File[] files = folder.listFiles();
for ( File file : files ) {
if ( file.exists() && file.isDirectory() )
return true;
}
return false;
}
}