code: public static OutputStream outputStreamFromURL(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.
               */
              String host = url.getHost();
              if (host == null || host.length() == 0) {
                  return new FileOutputStream(url.getPath());
              }
          }
          return url.openConnection().getOutputStream();
      }
docs: Method that tries to get a stream (ideally, optimal one) to write to
  the resource specified by given URL.
  Currently it just means creating a simple file output stream if the
  URL points to a (local) file, and otherwise relying on URL classes
  input stream creation method.