Ideas: First, to get the file size and you want to get, and then determine whether to file, if the file is determined that its size is equal to the specified size, is output. If it is a folder, then you need a recursive algorithm to operate the sub-file, written before the recursive algorithm to traverse file
Code:
package com.testHomework; import java.io.File; public class WalkFileTree { public static void main(String[] args) { File file = new File("D:/java文件"); Search(file,1024*100); } // find the specified folder all the files of the specified size public static void Search (File File, int size) { IF (file.isFile ()) { IF (file.length () == size) { System.out.println(file.getAbsolutePath()); } }else if(file.isDirectory()) { File[] files = file.listFiles(); for(File f:files) { Search(f,size); } } } }
operation result:
If you find an error, please leave a message chiefs pointed out! ! !