Is there a way to cancel a long running file open operation? Long delays due anti-virus scans, mapped network drives etc.
new FileInputStream("a_file_that_the_antivirus_" +
"will_process_for_minutes_before_returning.jar")
// process the contents...
In the above example, the first line can block, but I don't know any way to asynchronously cancel that operation (if we got the new inputstream object, cancellation is as easy as in.close(), but this question is not about that case).
Is it possible interrupt the open process - perhaps with NIO - or is there already a mechanism such as a simple Thread.interrupt() to cancel the open?
OS: mostly Windows XP+, Java 6+, the blocking is typically due some larger and deeper jar files - for example, Eclipse's plugins or my own complex apps.