类javax.swing.ProgressMonitorInputStream源码实例Demo

下面列出了怎么用javax.swing.ProgressMonitorInputStream的API类实例代码及写法,或者点击链接到github查看源代码。

private static boolean checkSHA256(File provingKey, Component parent) throws IOException {
    MessageDigest sha256;
    try {
        sha256 = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException impossible) {
        throw new IOException(impossible);
    }
    try (InputStream is = new BufferedInputStream(new FileInputStream(provingKey))) {
        ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(parent,
                LanguageUtil.instance().getString("proving.key.fetcher.option.pane.verify.progress.monitor.text"),
                is);
        pmis.getProgressMonitor().setMaximum(PROVING_KEY_SIZE);
        pmis.getProgressMonitor().setMillisToPopup(10);
        DigestInputStream dis = new DigestInputStream(pmis, sha256);
        byte [] temp = new byte[0x1 << 13];
        while(dis.read(temp) >= 0);
        byte [] digest = sha256.digest();

        return SHA256.equalsIgnoreCase(Util.bytesToHex(digest));
    }
}
 
private static boolean checkSHA256SG(File sproutGroth, Component parent) throws IOException {
    MessageDigest sha256;
    try {
        sha256 = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException impossible) {
        throw new IOException(impossible);
    }
    try (InputStream is = new BufferedInputStream(new FileInputStream(sproutGroth))) {
        ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(parent,
                LanguageUtil.instance().getString("sprout.groth.fetcher.option.pane.verify.progress.monitor.text"),
                is);
        pmis.getProgressMonitor().setMaximum(SPROUT_GROTH_SIZE);
        pmis.getProgressMonitor().setMillisToPopup(10);
        DigestInputStream dis = new DigestInputStream(pmis, sha256);
        byte [] temp = new byte[0x1 << 13];
        while(dis.read(temp) >= 0);
        byte [] digest = sha256.digest();
        
        return SHA256SG.equalsIgnoreCase(Util.bytesToHex(digest));
    }
}
 
private static boolean checkSHA256SS(File saplingSpend, Component parent) throws IOException {
    MessageDigest sha256;
    try {
        sha256 = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException impossible) {
        throw new IOException(impossible);
    }
    try (InputStream is = new BufferedInputStream(new FileInputStream(saplingSpend))) {
        ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(parent,
                LanguageUtil.instance().getString("sapling.spend.fetcher.option.pane.verify.progress.monitor.text"),
                is);
        pmis.getProgressMonitor().setMaximum(SAPLING_SPEND_SIZE);
        pmis.getProgressMonitor().setMillisToPopup(10);
        DigestInputStream dis = new DigestInputStream(pmis, sha256);
        byte [] temp = new byte[0x1 << 13];
        while(dis.read(temp) >= 0);
        byte [] digest = sha256.digest();

        return SHA256SS.equalsIgnoreCase(Util.bytesToHex(digest));
    }
}
 
源代码4 项目: spotbugs   文件: AbstractSwingGuiCallback.java
@Override
public InputStream getProgressMonitorInputStream(InputStream in, int length, String msg) {
    ProgressMonitorInputStream pmin = new ProgressMonitorInputStream(parent, msg, in);
    ProgressMonitor pm = pmin.getProgressMonitor();

    if (length > 0) {
        pm.setMaximum(length);
    }
    return pmin;
}
 
源代码5 项目: swift-explorer   文件: FileUtils.java
public static InputStream getInputStreamWithProgressMonitor(InputStream input, Component parentComponent, String message)
{
	if (input == null)
		return null ;
	Frame owner = null;
	if (parentComponent == null) 
		owner = SwingUtils.tryFindSuitableFrameOwner () ;
	InputStream in = new BufferedInputStream(
			new ProgressMonitorInputStream(
					(parentComponent == null) ? (owner) : (parentComponent),
					message, input));
	return in;
}
 
 类所在包
 同包方法