自己没事儿写的垃圾文件情理,算法很垃圾。凑合着能用。
=====================================================================
package com.datatransfer;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import javax.swing.JFileChooser;
public class test {
// tmp *._mp *.log *.gid *.chk *.old *.dmp *.bak *.hlp temp internet
static String[] SYSARRAY = { "tmp", "_mp", "gid", "chk", "old",
"dmp", "bak", "hlp", "temp", "internet" };
static HashMap
map = new HashMap
(); //删除结果分类
static StringBuffer sb = new StringBuffer(); //删除结果详细
static long count = 0; //删除个数
static long scanCount = 0; //扫描个数
static long node = 0; //子文件夹
public static void main(String[] args) throws IOException {
test t = new test();
java.util.Date now = new Date();
t.listFile("D:\\");
java.util.Date date=new Date();
TDoA(date,now);
System.err.println("共扫描 :" + scanCount + "个文件");
System.err.println("共删除了 :" + count + "个文件");
for (String str : SYSARRAY) {
System.err.println("共删除【"+str+"】类型垃圾文件 :"+map.get(str)+"个");
}
System.err.println("=====================详细信息=====================");
System.err.println(sb.toString());
}
/**
* 获取文件夹下的所有文件
*
* @author 2010-3-30上午10:56:51By Simon (赵振明).
*/
public void listFile(String pash) {
File f = new File(pash);
File[] array = f.listFiles();