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.fluo.stress.TrieMapRedIT.java

static int unique(File... dirs) throws Exception {

    ArrayList<String> args = new ArrayList<>(
            Arrays.asList("-D", "mapred.job.tracker=local", "-D", "fs.defaultFS=file:///"));
    for (File dir : dirs) {
        args.add(dir.toURI().toString());
    }/*from ww w.j  a v a2  s.  c o  m*/

    int ret = ToolRunner.run(new Unique(), args.toArray(new String[args.size()]));
    Assert.assertEquals(0, ret);
    return Unique.getNumUnique();
}

From source file:com.hangum.tadpole.engine.initialize.JDBCDriverLoader.java

/**
 * add jar loader of file//from ww  w .j  ava  2  s .co m
 * 
 * @param strFile
 * @throws Exception
 */
public static void addJarFile(String strFile) throws Exception {
    File file = new File(strFile);
    if (file.isFile()) {
        addJARLoader(new Object[] { file.toURI().toURL() });
    }
}

From source file:org.wso2.carbon.discovery.cxf.util.ClassAnnotationScanner.java

public static AnnotationDB getAnnotatedClasses(StandardContext context) {

    AnnotationDB db = new AnnotationDB();
    //        db.addIgnoredPackages("org.apache");
    db.addIgnoredPackages("org.codehaus");
    db.addIgnoredPackages("org.springframework");

    final String path = context.getRealPath("/WEB-INF/classes");
    URL resourceUrl = null;/*from w  w  w.  ja v a 2 s .  c o m*/
    URL[] urls = null;

    if (path != null) {
        final File fp = new File(path);
        if (fp.exists()) {
            try {
                resourceUrl = fp.toURI().toURL();
                urls = new URL[] { new URL(resourceUrl.toExternalForm()) };
                db.scanArchives(urls);
                return db;
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    return db;
}

From source file:com.openteach.diamond.osgi.Activator.java

public static void downloadAndInstallBundle(String bundleName) throws DiamondException {
    String version = getCurrentBundleVersion();
    String bundle = bundleName + "-" + version + ".jar.plugin";
    String containerPath = System.getProperty("HSF.CONTAINER.PATH");
    String outputDir = containerPath + File.separator + "plugins" + File.separator + "extra";
    try {/*  ww w .  ja v a  2  s  . co m*/
        BundleDownloader.download(bundle, outputDir);
    } catch (DiamondException e) {
        throw new DiamondException(String.format("bundle:%s, :", bundle), e);
    }
    try {
        File f = new File(outputDir, bundle);
        installAndStartBundle(f.toURI().toURL().toExternalForm());
    } catch (DiamondException e) {
        throw new DiamondException("bundle, ", e);
    } catch (MalformedURLException e) {
        throw new DiamondException("bundle, ", e);
    }
}

From source file:com.jkoolcloud.tnt4j.streams.utils.ZorkaAttach.java

/**
 * Entry point for loading Zorka as java agent.
 *
 * @param zorkaHomePath/*from   w w  w.  j a  va2  s .c  om*/
 *            Zorka home dir path
 * @param inst
 *            JVM instrumentation
 * @throws Exception
 *             if exception occurs while loading java agent
 *
 * @see AgentMain#premain(String, Instrumentation)
 */
public static void agentmain(final String zorkaHomePath, final Instrumentation inst) throws Exception {
    final String zorkaDirPath = new File(zorkaHomePath).getAbsolutePath();
    System.setProperty("zorka.home.dir", zorkaDirPath);
    LOGGER.log(OpLevel.DEBUG,
            StreamsResources.getString(ZorkaConstants.RESOURCE_BUNDLE_NAME, "ZorkaAttach.zorka.path"),
            zorkaDirPath);

    File zorkaPath = new File(zorkaDirPath);
    final String[] classPathEntries = zorkaPath.list(new WildcardFileFilter("*.jar")); // NON-NLS
    if (classPathEntries != null) {
        for (String classPathEntry : classPathEntries) {
            File pathFile = new File(classPathEntry);
            extendClasspath(pathFile.toURI().toURL());
        }
    }
    AgentMain.premain(null, inst);
}

From source file:com.twinsoft.convertigo.engine.util.FileUtils.java

public static String toUriString(File file) throws MalformedURLException {
    String fileUrl = file.toURI().toURL().toString();
    return fileUrl;
}

From source file:com.google.mr4c.content.RelativeContentFactory.java

public static String toRelativeFilePath(File file, File ancestor) {
    checkRelated(file, ancestor);//from   w ww  .j a v  a 2  s.c  om
    URI fileUri = file.toURI();
    URI ancestorUri = ancestor.toURI();
    URI relativeUri = ancestorUri.relativize(fileUri);
    return relativeUri.getPath();
}

From source file:de.micromata.genome.util.runtime.DynamicClassPath.java

public static URL createClUrl(File f) {
    try {// ww  w.ja v  a2  s  . com
        URL ret;
        if (f.isDirectory() == true) {
            ret = f.toURI().toURL();
        } else {
            // ret = new URL("jar", "", f.getAbsolutePath());
            ret = f.toURI().toURL();
        }
        String s = ret.toExternalForm();
        return ret;
    } catch (MalformedURLException ex) {
        throw new RuntimeException("Cannot extend class oath because of invalid url: " + f.toURI());
    }
}

From source file:com.geewhiz.pacify.utils.FileUtils.java

public static URL getFileUrl(File file) {
    try {//from   w ww .  ja  v a2  s .co  m
        return file.toURI().toURL();
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.shadwelldacunha.byteswipe.core.Utilities.java

public static String readFileAsString(File file) throws IOException {
    byte[] encoded = Files.readAllBytes(Paths.get(file.toURI()));
    return new String(encoded, guessEncoding(encoded));
}