title: Java InputStream Locking
body: <p>I am using an InputStream to stream a file over the network. </p>
  
  <p>However if my network goes down the the process of reading the file the read method blocks and is never recovers if the network reappears. </p>
  
  <p>I was wondering how I should handle this case and should some exception not be thrown if the InputStream goes away. </p>
  
  <p>Code is like this. </p>
  
  <pre><code>Url someUrl = new Url("http://somefile.com");
  InputStream inputStream = someUrl.openStream();
  byte[] byteArray = new byte[];
  int size = 1024;
  inputStream.read(byteArray,0,size);
  </code></pre>
  
  <p>So somewhere after calling read the network goes down and the read method blocks. </p>
  
  <p>How can i deal with this situation as the read doesn't seem to throw an exception. </p>