Java Path to URL getUrlForLocalPath(String path)

Here you can find the source of getUrlForLocalPath(String path)

Description

get Url For Local Path

License

LGPL

Declaration

public static URL getUrlForLocalPath(String path) throws IOException 

Method Source Code


//package com.java2s;
/*//from w w w  . j a  va 2 s .c  o m
 * This file is part of VirtualFile.
 *
 * Copyright 2016 by Bernd Riedl <bernd.riedl@gmail.com>
 *
 * Licensed under GNU Lesser General Public License 3.0 or later.
 * Some rights reserved. See COPYING, AUTHORS.
 */

import java.io.IOException;

import java.net.URL;

public class Main {
    public static URL getUrlForLocalPath(String path) throws IOException {
        return new URL(new java.io.File(path).toURI().toURL().toString()
                + (path.endsWith(java.io.File.separator) ? "/" : ""));
    }
}

Related

  1. getURL(String path)
  2. getURL(String path, URL context)
  3. getUrl(String pluginId, String relativePath)
  4. getURL(String schema, String host, String path)
  5. getUrl(URL base, String path)
  6. getURLFromClassPath(String source)
  7. getURLFromPath(String jarPath)
  8. getUrlFromPath(String path)
  9. getUrlFromUrlPath(String path)