Java ProgressInputStream没有正确弹出

时间:2018-04-23 16:12:24

标签: java swing

我的ProgressInputStream有问题。框架弹出但没有什么可看的。 谢谢,抱歉我的英文不好

问题:
The Problem:

public byte[] createMD5Checksum(String filename) throws Exception {        
    MessageDigest complete = null;
    try {
        InputStream in = new BufferedInputStream(new ProgressMonitorInputStream(MainFrame.this, "Reading: " +filename, new FileInputStream(filename)));
        byte[] buffer = new byte[1024];
        int numRead;
        complete = MessageDigest.getInstance("MD5");
        do {
            numRead = in.read(buffer);
            if (numRead > 0) {
                complete.update(buffer, 0, numRead);
            }
        } while (numRead != -1);
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return complete.digest();
}

0 个答案:

没有答案