code: public static InputStream inputStreamFromURL(URL url) throws IOException
      {
          if ("file".equals(url.getProtocol())) {
              /* As per [WSTX-82], can not do this if the path refers
               * to a network drive on windows. This fixes the problem;
               * might not be needed on all platforms (NFS?), but should not
               * matter a lot: performance penalty of extra wrapping is more
               * relevant when accessing local file system.
               */
              String host = url.getHost();
              if (host == null || host.length() == 0) {
                  /* One more test: if there are quoted characters, need
                   * to decoded [WSTX-207]:
                   */
                  String path = url.getPath();
                  if (path.indexOf('%') >= 0) {
                      path = URLDecoder.decode(path, "UTF-8");
                  }
                  return new FileInputStream(path);
              }
          }
          return url.openStream();
      }
docs: Method that tries to get a stream (ideally, optimal one) to read from
  the specified URL.
  Currently it just means creating a simple file input stream if the
  URL points to a (local) file, and otherwise relying on URL classes
  input stream creation method.