congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
URL.toExternalForm
Code IndexAdd Tabnine to your IDE (free)

How to use
toExternalForm
method
in
java.net.URL

Best Java code snippets using java.net.URL.toExternalForm (Showing top 20 results out of 21,519)

Refine searchRefine arrow

  • URL.<init>
  • File.<init>
  • URI.toURL
  • File.toURI
  • List.add
  • URL.getProtocol
  • File.exists
origin: gocd/gocd

  public String urlFor(String pathAfterContext) {
    try {
      return new URL(protocol, host, port, contextPath + pathAfterContext).toExternalForm();
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    }
  }
}
origin: org.freemarker/freemarker

public String getXmlSystemId() throws IOException {
  return file.toURI().toURL().toExternalForm();
}
origin: ffay/lanproxy

  private InputStream jksDatastore(String jksPath) throws FileNotFoundException {
    URL jksUrl = getClass().getClassLoader().getResource(jksPath);
    if (jksUrl != null) {
      logger.info("Starting with jks at {}, jks normal {}", jksUrl.toExternalForm(), jksUrl);
      return getClass().getClassLoader().getResourceAsStream(jksPath);
    }

    logger.warn("No keystore has been found in the bundled resources. Scanning filesystem...");
    File jksFile = new File(jksPath);
    if (jksFile.exists()) {
      logger.info("Loading external keystore. Url = {}.", jksFile.getAbsolutePath());
      return new FileInputStream(jksFile);
    }

    logger.warn("The keystore file does not exist. Url = {}.", jksFile.getAbsolutePath());
    return null;
  }
}
origin: apache/hive

private void addJarLRByClass(Class<?> clazz, final Map<String, LocalResource> lrMap) throws IOException,
  LoginException {
 final File jar =
   new File(Utilities.jarFinderGetJar(clazz));
 final String localJarPath = jar.toURI().toURL().toExternalForm();
 final LocalResource jarLr = createJarLocalResource(localJarPath);
 lrMap.put(DagUtils.getBaseName(jarLr), jarLr);
}
origin: RaiMan/SikuliX2

 uFolder = new URL(uFolder.toExternalForm().replaceAll(" ", "%20"));
} catch (Exception ex) {
 fFolder = new File(uFolder.toURI());
 log.debug("resourceList: having folder:\n%s", fFolder);
 String sFolder = normalizeAbsolute(fFolder.getPath(), false);
  sFolder = sFolder.substring(1);
 files.add(sFolder);
 files = doResourceListFolder(new File(sFolder), files, filter);
 files.remove(0);
 return files;
} catch (Exception ex) {
 if (!"jar".equals(uFolder.getProtocol())) {
  log.debug("resourceList:\n%s", folder);
  log.error("resourceList: URL neither folder nor jar:\n%s", ex);
origin: eclipse-vertx/vert.x

 private static List<JavaFileObject> browseJar(URL packageFolderURL) {
  List<JavaFileObject> result = new ArrayList<>();
  try {
   String jarUri = packageFolderURL.toExternalForm().split("!")[0];
   JarURLConnection jarConn = (JarURLConnection) packageFolderURL.openConnection();
   String rootEntryName = jarConn.getEntryName();
   int rootEnd = rootEntryName.length() + 1;

   Enumeration<JarEntry> entryEnum = jarConn.getJarFile().entries();
   while (entryEnum.hasMoreElements()) {
    JarEntry jarEntry = entryEnum.nextElement();
    String name = jarEntry.getName();
    if (name.startsWith(rootEntryName) && name.indexOf('/', rootEnd) == -1 && name.endsWith(CLASS_FILE)) {
     String binaryName = name.replaceAll("/", ".").replaceAll(CLASS_FILE + "$", "");
     result.add(new CustomJavaFileObject(URI.create(jarUri + "!/" + name), JavaFileObject.Kind.CLASS, binaryName));
    }
   }
  } catch (Exception e) {
   throw new RuntimeException(packageFolderURL + " is not a JAR file", e);
  }
  return result;
 }
}
origin: Atmosphere/atmosphere

final boolean isVfs = url.getProtocol() != null && url.getProtocol().startsWith("vfs");
if ("file".equals(url.getProtocol()) || isVfs) {
  final File dir = toFile(url);
  if (dir.isDirectory()) {
    if (idx > -1) {
      jarPath = jarPath.substring(0, idx + 4);
      final File jarFile = new File(jarPath);
      if (jarFile.isFile() && jarFile.exists()) {
        files.add(jarFile);
        print("Add jar file from VFS: '%s'", jarFile);
    loadJarContent((JarURLConnection) url.openConnection(), packageName, streams);
  } catch (ClassCastException cce) {
    throw new AssertionError("Not a File: " + url.toExternalForm());
    try {
      String u = url.toExternalForm();
      if (u.startsWith("zip:")) {
        u = u.substring(4);
      jarFile = toFile(new URL(u));
    } catch (Exception ex) {
      throw new AssertionError("Not a File: " + url.toExternalForm());
origin: Dreampie/Resty

rootPath = new File(classPath).getParentFile().getParentFile().getCanonicalFile().getAbsolutePath() + "/";
File webappDir = new File(rootPath + resourceBase);
if (!webappDir.exists() || !webappDir.isDirectory()) {
 throw new IllegalArgumentException("Could not found webapp directory or it is not directory.");
resourceUrls.add(webappUrl);
while (staticUrls.hasMoreElements()) {
 staticURL = staticUrls.nextElement();
 if (staticURL != null) {
  resourceUrls.add(staticURL.toExternalForm());
origin: ronmamo/reflections

while (urls.hasMoreElements()) {
  final URL url = urls.nextElement();
  int index = url.toExternalForm().lastIndexOf(resourceName);
  if (index != -1) {
    result.add(new URL(url, url.toExternalForm().substring(0, index)));
  } else {
    result.add(url);
origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document doc) {
  List<String> result = new ArrayList<>();
  List<String> urlsToGrab = new ArrayList<>();
  if (url.toExternalForm().contains("/manga/")) {
    for (Element el : doc.select("div.chapter-list > div.row > span > a")) {
      urlsToGrab.add(el.attr("href"));
    }
    Collections.reverse(urlsToGrab);
    for (String url : urlsToGrab) {
      result.addAll(getURLsFromChap(url));
    }
  } else if (url.toExternalForm().contains("/chapter/")) {
    result.addAll(getURLsFromChap(doc));
  }
  return result;
}
origin: RipMeApp/ripme

private void handleURL(String theUrl, String id, String title) {
  URL originalURL;
  try {
    originalURL = new URL(theUrl);
  } catch (MalformedURLException e) {
    return;
    String url = urls.get(0).toExternalForm();
    Pattern p = Pattern.compile("https?://i.reddituploads.com/([a-zA-Z0-9]+)\\?.*");
    Matcher m = p.matcher(url);
      addURLToDownload(urls.get(0), new File(savePath));
      URL urlToDownload = parseRedditVideoMPD(urls.get(0).toExternalForm());
      if (urlToDownload != null) {
        LOGGER.info("url: " + urlToDownload + " file: " + savePath);
        addURLToDownload(urlToDownload, new File(savePath));
origin: webx/citrus

private InputSource(Object source, String systemId) {
  assertNotNull(source, "source");
  if (source instanceof URL) {
    try {
      this.source = new File(((URL) source).toURI().normalize()); // convert URL to File
    } catch (Exception e) {
      this.source = source;
    }
  } else if (source instanceof File) {
    this.source = new File(((File) source).toURI().normalize()); // remove ../
  } else {
    this.source = source;
  }
  if (this.source instanceof URL) {
    this.systemId = ((URL) this.source).toExternalForm();
  } else if (this.source instanceof File) {
    this.systemId = ((File) this.source).toURI().toString();
  } else {
    this.systemId = trimToNull(systemId);
  }
}
origin: org.netbeans.api/org-openide-filesystems

String protocol = url.getProtocol();
      return new URL(jarPath);
        new Object[] {
          mue.getMessage(),
          url.toExternalForm(),
          jarPath
        });
origin: stackoverflow.com

webapp.setDescriptor(location.toExternalForm() + "/WEB-INF/web.xml");
webapp.setServer(server);
webapp.setWar(location.toExternalForm());
webapp.setTempDirectory(new File("/path/to/webapp-directory"));
origin: javax.xml.bind/jaxb-api

  xml=new URI((String)xml);
} catch (URISyntaxException e) {
  xml=new File((String)xml);
xml=uri.toURL();
return new StreamSource(url.toExternalForm());
origin: org.netbeans.api/org-openide-filesystems

  wasDir = entry.isDirectory();
  LOG.finest("urlForArchiveOrDir:toURI:entry");   //NOI18N
  u = Utilities.toURI(entry).toURL();
  isDir = entry.isDirectory();
} while (wasDir ^ isDir);
  return getArchiveRoot(u);
} else if (isDir) {
  assert u.toExternalForm().endsWith("/");    //NOI18N
  return u;
} else if (!entry.exists()) {
  if (!u.toString().endsWith("/")) {  //NOI18N
    u = new URL(u + "/"); // NOI18N
origin: cucumber/cucumber-jvm

private URLOutputStream(URL url, String method, Map<String, String> headers, int expectedResponseCode) throws IOException {
  this.url = url;
  this.method = method;
  this.expectedResponseCode = expectedResponseCode;
  if (url.getProtocol().equals("file")) {
    File file = new File(url.getFile());
    ensureParentDirExists(file);
    out = new FileOutputStream(file);
    urlConnection = null;
  } else if (url.getProtocol().startsWith("http")) {
    urlConnection = (HttpURLConnection) url.openConnection();
    urlConnection.setRequestMethod(method);
    urlConnection.setDoOutput(true);
    for (Map.Entry<String, String> header : headers.entrySet()) {
      urlConnection.setRequestProperty(header.getKey(), header.getValue());
    }
    out = urlConnection.getOutputStream();
  } else {
    throw new IllegalArgumentException("URL Scheme must be one of file,http,https. " + url.toExternalForm());
  }
}
origin: org.netbeans.api/org-openide-filesystems

private static URL toURL(File fFile, FileObject fo) throws MalformedURLException {
  URL retVal = Utilities.toURI(fFile).toURL();
  if (retVal != null && fo.isFolder()) {
    // #155742,160333 - URL for folder must always end with slash
    final String urlDef = retVal.toExternalForm();
    final String pathSeparator = "/";//NOI18N
    if (!urlDef.endsWith(pathSeparator)) {
      retVal = new URL(urlDef + pathSeparator);
    }
  }
  return retVal;
}
origin: org.elasticsearch/elasticsearch

if ("file".equalsIgnoreCase(url.getProtocol())) {
  if (url.getHost() == null || "".equals(url.getHost())) {
    return path.toUri().toURL();
} else if ("jar".equals(url.getProtocol())) {
  String file = url.getFile();
  int pos = file.indexOf("!/");
  URL internalUrl = new URL(filePath);
  URL normalizedUrl = resolveRepoURL(internalUrl);
  if (normalizedUrl == null) {
    return null;
  return new URL("jar", "", normalizedUrl.toExternalForm() + jarTail);
} else {
origin: cucumber/cucumber-jvm

static String filePath(URL fileUrl) {
  if (!"file".equals(fileUrl.getProtocol())) {
    throw new CucumberException("Expected a file URL:" + fileUrl.toExternalForm());
  }
  try {
    return fileUrl.toURI().getSchemeSpecificPart();
  } catch (URISyntaxException e) {
    throw new CucumberException(e);
  }
}
java.netURLtoExternalForm

Javadoc

Returns a string containing a concise, human-readable representation of this URL.

Popular methods of URL

  • <init>
  • openStream
    Opens a connection to this URL and returns anInputStream for reading from that connection. This meth
  • openConnection
    Returns a new connection to the resource referred to by this URL.
  • toString
    Constructs a string representation of this URL. The string is created by calling the toExternalForm
  • getPath
    Gets the path part of this URL.
  • toURI
    Returns a java.net.URI equivalent to this URL. This method functions in the same way as new URI (thi
  • getProtocol
    Gets the protocol name of this URL.
  • getFile
    Gets the file name of this URL. The returned file portion will be the same as getPath(), plus the c
  • getHost
    Gets the host name of this URL, if applicable. The format of the host conforms to RFC 2732, i.e. for
  • getPort
    Gets the port number of this URL.
  • getQuery
    Gets the query part of this URL.
  • equals
    Compares this URL for equality with another object. If the given object is not a URL then this metho
  • getQuery,
  • equals,
  • getRef,
  • getUserInfo,
  • getAuthority,
  • hashCode,
  • getDefaultPort,
  • getContent,
  • setURLStreamHandlerFactory

Popular in Java

  • Creating JSON documents from java classes using gson
  • setContentView (Activity)
  • getContentResolver (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Runner (org.openjdk.jmh.runner)
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now