how to download file using interruptiblechannel? (NIO)
<p>When I got an incoming call then I have to <strong>immediately</strong> interrupt my long running thread. I want to use Thread.interrupt() method to do that.</p>

<p>Reference says:</p>

<pre><code>Threads blocked in an I/O operation of an InterruptibleChannel will 
have their interrupt status set and receive an ClosedByInterruptException. 
Also, the channel will be closed.
</code></pre>

<p>In my thread I'm downloading a file via HTTP, so I want to use InterruptibleChannel in order to immediately stop downloading. Could you give me some source code, how to download a file using InterruptibleChannel?</p>

<p>this solution is not okay for me, because Thread.interrupt() doesn't interrupt blocking IO:</p>

<pre><code>while ((length = httpIn.read(buffer)) &gt; 0) {
       if(Thread.interrupted())
          ....
       else
       {
            fileOut.write(buffer, 0, length);
            fileSize += length;
       }
}
</code></pre>
