public class FileSize {
public static void main(String[] args) {
//src下面及時txt文件
String srcPath="D:\\test\\src";
String destPath="D:\\test\\dests\\";
File srcFile = new File(srcPath);
File[] srcFiles = srcFile.listFiles();
//把srcPath下爲空和字節數小於50的txt文本移到destPath下
System.out.println("篩選文件開始...");
long startTime = System.currentTimeMillis();
for (File files : srcFiles) {
if(files.length()==0||files.length()<50){
files.renameTo(new File(destPath+files.getName()));
}
}
long endTime=System.currentTimeMillis();
System.out.println("篩選文本耗時:"+(endTime-startTime));
}spa
}get