title: Cannot read from InputStream
body: <p>My current code is this:</p>
  
  <pre><code>try {
      inputStream is = (new URL(urlpath).openStream());
      ByteArrayOutputStream os = new ByteArrayOutputStream();
          for (int len; (len = is.read(data)) != -1;) {
              os.write(data, 0, len);
          }
          os.flush();
          data = os.toByteArray();
      } catch (Exception e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>But <code>is.read(data)</code> always returns <code>-1</code>. I do not understand why it is not working. I used same code at other places, it is working, but in this application, this code is not working. What should be problem with the url path?</p>