Example usage for java.io File toURI

List of usage examples for java.io File toURI

Introduction

In this page you can find the example usage for java.io File toURI.

Prototype

public URI toURI() 

Source Link

Document

Constructs a file: URI that represents this abstract pathname.

Usage

From source file:io.hops.util.RMStorageFactory.java

private static void addToClassPath(String s) throws StorageInitializtionException {
    try {/* w  w  w.ja  v  a  2s.  c o  m*/
        File f = new File(s);
        URL u = f.toURI().toURL();
        URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
        Class urlClass = URLClassLoader.class;
        Method method = urlClass.getDeclaredMethod("addURL", new Class[] { URL.class });
        method.setAccessible(true);
        method.invoke(urlClassLoader, new Object[] { u });
    } catch (MalformedURLException ex) {
        throw new StorageInitializtionException(ex);
    } catch (IllegalAccessException ex) {
        throw new StorageInitializtionException(ex);
    } catch (IllegalArgumentException ex) {
        throw new StorageInitializtionException(ex);
    } catch (InvocationTargetException ex) {
        throw new StorageInitializtionException(ex);
    } catch (NoSuchMethodException ex) {
        throw new StorageInitializtionException(ex);
    } catch (SecurityException ex) {
        throw new StorageInitializtionException(ex);
    }
}

From source file:com.github.fge.jsonschema.main.cli.Main.java

private static String getCwd() throws IOException {
    final File cwd = new File(System.getProperty("user.dir", ".")).getCanonicalFile();
    return URIUtils.normalizeURI(cwd.toURI()).toString();
}

From source file:com.liferay.blade.samples.test.BladeCLIUtil.java

public static String installBundle(File file) throws Exception {
    String output = execute("sh", "install", file.toURI().toString());

    String bundleID = output.substring(output.indexOf("bundle id:") + 11,
            output.indexOf("\n", output.indexOf("bundle id:")));

    if (output.contains("Failed") || output.contains("IOException")) {
        throw new Exception(output);
    }//from  w  w w.  j a va  2  s.  c  o  m

    return bundleID;
}

From source file:com.ibm.wala.cast.js.nodejs.NodejsRequiredCoreModule.java

public static NodejsRequiredCoreModule make(String name) throws IOException {
    if (!names.containsKey(name)) {
        java.nio.file.Path p = Files.createTempDirectory("nodejs");
        File f = new File(p.toFile(), name + ".js");
        f.deleteOnExit();/*from   www .j a  v a2 s .  c o  m*/
        p.toFile().deleteOnExit();
        names.put(name, f);
    }
    File file = names.get(name);
    TemporaryFile.streamToFile(file, getModule(name));
    SourceFileModule sourceFileModule = CAstCallGraphUtil.makeSourceModule(file.toURI().toURL(),
            file.getName());
    return new NodejsRequiredCoreModule(file, sourceFileModule);
}

From source file:com.google.gwt.dev.resource.impl.ZipFileClassPathEntry.java

/**
 * @return the {@link ZipFileClassPathEntry} instance for given jar or zip
 *         file, may be shared with other users.
 *///from  w w  w.  jav  a2s .  c  om
public static synchronized ZipFileClassPathEntry get(File zipFile) throws IOException {
    String location = zipFile.toURI().toString();
    ZipFileClassPathEntry entry = entryCache.get(location);
    if (entry == null) {
        entry = new ZipFileClassPathEntry(zipFile);
        entryCache.put(location, entry);
    }
    return entry;
}

From source file:de.nava.informa.parsers.OPMLParser.java

public static Collection<FeedIF> parse(File aFile) throws IOException, ParseException {
    URL aURL;//from   w  ww . j a va  2 s .  com
    try {
        aURL = aFile.toURI().toURL();
    } catch (java.net.MalformedURLException e) {
        throw new IOException("File " + aFile + " had invalid URL " + "representation.");
    }
    return parse(new InputSource(aURL.toExternalForm()), aURL);
}

From source file:net.erdfelt.android.sdkfido.sdks.SourceOriginsLoader.java

public static SourceOrigins load(File file) throws IOException {
    if (!file.exists()) {
        throw new FileNotFoundException("Unable to find file: " + file);
    }/*from  www. ja v a  2  s  .  c  o m*/
    return load(file.toURI().toURL());
}

From source file:br.msf.maven.utils.IOUtils.java

public static String getRelativePath(final File base, final File child) {
    if (base == null || child == null) {
        throw new IllegalArgumentException("Cannot be null.");
    }//from  w ww  . j  av a2 s  .co  m
    return base.toURI().relativize(child.toURI()).getPath();
}

From source file:gov.va.vinci.leo.tools.LeoUtils.java

/**
 * Return a URI string locator for the File object provided.
 *
 * @param f  the file to get URI for.//from   w ww .ja  va 2  s.  c om
 * @return   the file URI.
 */
public static String getFileURI(File f) {
    return f.toURI().toString();
}

From source file:com.jtstand.swing.Main.java

public static URI resolve(String uristr) {
    File curdirrel = new File(".");
    File curdir = new File(curdirrel.getAbsolutePath());
    URI cururi = curdir.toURI().normalize();
    log.trace("URI of the current directory: " + cururi.toString());
    return resolve(uristr, cururi);
}