Example usage for java.io File wait

List of usage examples for java.io File wait

Introduction

In this page you can find the example usage for java.io File wait.

Prototype

public final void wait() throws InterruptedException 

Source Link

Document

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Usage

From source file:com.eviware.loadui.impl.conversion.ReferenceToFileConverter.java

@Override
public File convert(Reference source) {
    if (source.getId().charAt(0) == ':')
        return new File(source.getId().substring(1));

    File target = getOrCreate(source);
    String hash = source.getId();

    synchronized (target) {
        while (!target.exists() || filesInProgress.contains(hash)) {
            try {
                log.debug("waiting for {}", source.getId());
                target.wait();
            } catch (InterruptedException e) {
                log.debug("got waken up, was waiting for {}", source.getId());
            }//from www.  j a  v a2s . c  om
        }
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(target);
            String md5Hex = DigestUtils.md5Hex(fis);
            log.debug("target is: {} and is {} bytes with hash " + md5Hex, target, target.length());
        } catch (IOException e) {
            log.error("Exception while verifying hash", e);
            e.printStackTrace();
        } finally {
            Closeables.closeQuietly(fis);
        }
    }

    return target;
}