我来贴下自己的代码,还有很多不完善的地方,先这样吧 
 
/* 
 功能需求:实现文档的备份需求 
 1.被备份文档一定不旧于备份档,具体参考指标包括但不限于文件的mtime,size 
 2.每天备份一次 
 3.尽量优化备份速速 
 */ 
import java.io.*; 
import java.util.*; 
import java.text.*; 
public class BackUp  
{ 
        public static void main(String[] args) throws Exception 
        { 
                 File OLD = new File("d:\\oracle.txt");                //原始档 
                 File NEW = new File("d:\\oracle_backup.txt");                //备份档 
                 ArrayList<Attr> al_new =        new ArrayList<>();                //创建放值Attr的容器                                                 
                 while(true)                                //用于完成每天自动备份的功能 
                 { 
                         int count_old = al_new.size();                                //备份之前的大小 
                        int count_new = action(OLD,NEW,al_new).size();                                //备份之后的大小 
                         if(count_new == count_old) 
                         { 
                                 System.out.println("今天的备份工作已经完成!!!!!!"); 
                                 continue; 
                         } 
                                 action(OLD,NEW,al_new); 
                                 System.out.println("备份成功!!!!");                //提示备份数据传输完毕          
                                 Thread.sleep(86400000);                                //进程休眠24小时 
                 } 
        } 
         
        public static ArrayList<Attr> action(File OLD,File NEW,ArrayList<Attr> al_new) throws IOException 
        { 
                /*获得被备份文档的属性*/ 
                Date date_old = new Date(); 
                date_old.setTime(OLD.lastModified()); 
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
                String mtime_old = sdf.format(date_old);                        //获取备份档的mtime 
                long size_old = OLD.length(); 
                Attr temp_old = new Attr(mtime_old,size_old); 
                 
                if(al_new.size() > 1 && temp_old.equals(al_new.get(al_new.size() - 1))) 
                { 
                        return al_new;                                         
                } 
                BufferedInputStream bis = new BufferedInputStream(new FileInputStream(OLD));                //将旧文档于读取流相关联 
                BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(NEW,true)); 
                byte[] buf = new byte[1024 * 1024 * 4];                //缓冲区设置为4M 
                int len_new = 0; 
                while((len_new = bis.read(buf)) != -1)                                //备份数据过程 
                { 
                        bos.write(buf,0,len_new); 
                } 
                bis.close();                                //关闭流,释放资源 
                bos.close();                        //关闭流,释放资源 
                 
                /*第一次备份完毕之后开始记录backup档的文件属性*/ 
                Date date_new = new Date(); 
                date_new.setTime(NEW.lastModified()); 
                SimpleDateFormat sdfx = new SimpleDateFormat("yyyy-MM-dd"); 
                String mtime_new = sdfx.format(date_new);                        //获取备份档的mtime 
                //System.out.println(mtime); 
                long size_new = NEW.length(); 
                //System.out.println(size);                                //获取备份档的size 
                 
                /*将文档属性添加进入Attr容器中,该容器使用ArrayList*/ 
                //        ArrayList<Attr> al_new = new ArrayList<>(); 
                Attr temp_new = new Attr(mtime_new,size_new); 
                        al_new.add(temp_new); 
        //                /*测试al_new中的对象是否符合预期*/ 
        //                for(Attr a : al_new) 
        //                                System.out.println(a); 
                        //int num = al_new.size(); 
                        //System.out.println(num); 
                        return al_new; 
        } 
} 
class Attr<String,Long>                                //定义一个对象,用于存放mtime和size 
{ 
        private String mtime; 
        private long size; 
        Attr(){} 
        Attr(String mtime,long size) 
        { 
                this.mtime = mtime; 
                this.size = size; 
        } 
        public String getMtime() 
        { 
                return mtime; 
        } 
        public long getSize() 
        { 
                return size; 
        } 
        public boolean equals(Object obj) 
        { 
                Attr a = (Attr)obj;  
                return this.mtime.equals(a.getMtime()) || this.size == a.getSize(); 
        } 
}  
 
 
 
/* 
 软件整体结构也就上面那样了,我想说说功能可以改进的地方: 
 1.该软件在运行之后会一直占用内存,主程序不会退出,所以我想能否另外在做一个线程,通过监控服务器时间来达到时间到通过线程启动主程序的目的,该想法暂时没有办法实现(还没学多线程) 
 2.代码结构不够漂亮,说明基本功不扎实 
 3.Attr使用内部类实现可能效果更好 
 PS:欢迎讨论并提出宝贵意见(逃匿) 
 */ 
 |