以下是本人实现的一个对Java项目下的指定格式的文件修改进行记录的公共类: // Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov Date: 2007-12-11 锟斤拷锟斤拷 09:16:41 // Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version! // Decompiler options: packimports(3) // Source File Name: FileRecorder.java package com.sunfairs.util; import java.io.*; import java.text.DateFormat; import java.util.*; public class FileRecorder { class MyFilter implements FileFilter { private String[] fileName; public MyFilter(){ } public MyFilter(String[] fileName) { this.fileName = fileName; } public String[] getFileName() { return fileName; } public void setFileName(String[] fileName) { this.fileName = fileName; } public boolean accept(File pathname) { return !pathname.getName().endsWith(".class")&& !pathname.getName().endsWith(".properties")&& !pathname.getName().equalsIgnoreCase("CVS")&& !pathname.getName().endsWith(".txt")&& !pathname.getName().endsWith(".classpath"); } } public FileRecorder() { fileNames = new HashMap(); count = 0; } public String getFilePath() { return filePath; } public void setFilePath(String filePath) { this.filePath = filePath; } public Map getAllFiles(File path) { // String[]fileExtends={".jsp",".hbm.xml"}; File paths[] = path.listFiles(new MyFilter()); for(int i = 0; i < paths.length; i++) if(paths[i].isFile()) { Date date = new Date(paths[i].lastModified()); DateFormat format = DateFormat.getDateInstance(); String day = format.format(date); Date today = new Date(); String days = format.format(today); if(day.equals(days)) { fileNames.put(Integer.valueOf(count), paths[i].getName()); count++; } } else { getAllFiles(paths[i]); } return fileNames; } public static void main(String args[]) { FileRecorder recorder = new FileRecorder(); File path = new File("D://WorkSpace//Shop"); Map fileNames = recorder.getAllFiles(path); Date today = new Date(); DateFormat format = DateFormat.getDateInstance(); String days = format.format(today); try { File logFile = new File((new StringBuilder()).append("D://WorkSpace//Shop//logs//FileModified_").append(days).append(".log").toString()); FileOutputStream output = new FileOutputStream(logFile, true); for(int i = 0; i < fileNames.size(); i++) { String fileName = (String)fileNames.get(Integer.valueOf(i)); output.write((new String((new StringBuilder()).append(fileName).append(" ").toString())).getBytes()); } } catch(FileNotFoundException e) { e.printStackTrace(); } catch(IOException e) { e.printStackTrace(); } } private String filePath; private Map fileNames; private int count; }