首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

java 判断两个资料是否相同

2013-03-14 
java 判断两个文件是否相同【create md5】按钮用于生成source file的文件内容长度和MD5值。运行主类:CheckSam

java 判断两个文件是否相同

【create md5】按钮用于生成source file的文件内容长度和MD5值。运行主类:CheckSameApp?

?swingwork类:CheckSameSwingWorker
package com.hw.util;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.List;import javax.swing.SwingWorker;import com.common.util.MyProcess;public class CheckSameSwingWorker extends SwingWorker<Boolean, Character>{    private BufferedReader br_right       = null;    private BufferedReader br_error       = null;    private MyProcess      myprocess      = null;    private char           word           = ' ';    private int            tmp            = 0;    private boolean        isPrintVerbose = false;    private StringBuffer   stringbuf      = new StringBuffer();    public CheckSameSwingWorker(MyProcess myprocess, BufferedReader br)    {        this.br_right = br;        this.myprocess = myprocess;    }    public CheckSameSwingWorker(MyProcess myprocess)    {        this.myprocess = myprocess;        br_right = new BufferedReader(new InputStreamReader(            myprocess.getInputStream()), 4096);        br_error = new BufferedReader(new InputStreamReader(            myprocess.getErrorStream()), 4096);    }    @Override    protected Boolean doInBackground() throws Exception    {        while ((tmp = br_right.read()) != -1)        {            word = (char) tmp;            publish(word);        }        while ((tmp = br_error.read()) != -1)        {            word = (char) tmp;            publish(word);        }        if (isPrintVerbose)        {            System.out.println("doInBackground() over");        }        return true;    }    @Override    protected void process(List<Character> chunks)    {        for (char temp : chunks)        {            {//                System.out.print(temp);                this.stringbuf.append(temp);            }        }    }    public StringBuffer getStringbuf()    {        return stringbuf;    }    /***     * main thread can't execute next command(below waitFor())      * until done() is executed     */    @Override    protected void done()    {        if (isPrintVerbose)        {            System.out.println("done() is finish");        }        try        {            br_right.close();        }        catch (IOException e)        {            e.printStackTrace();        }        this.myprocess.stopLoop();    }}
?依赖的jar是io0007-find_progess.jar在附件中。

热点排行