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:de.fenvariel.mavenfreemarker.FreemarkerPlugin.java

private String readFile(File file) throws IOException {
    byte[] bytes = Files.readAllBytes(Paths.get(file.toURI()));
    return new String(bytes);
}

From source file:boa.evaluator.BoaEvaluator.java

public void evaluate() {
    final String[] actualArgs = createHadoopProgramArguments();
    final File srcDir = new File(this.COMPILATION_DIR);

    try {//from ww  w. ja  va 2  s .  c om
        final URL srcDirUrl = srcDir.toURI().toURL();

        final ClassLoader cl = new URLClassLoader(new URL[] { srcDirUrl }, ClassLoader.getSystemClassLoader());
        final Class<?> cls = cl.loadClass("boa." + jarToClassname(this.PROG_PATH));
        final Method method = cls.getMethod("main", String[].class);

        method.invoke(null, (Object) actualArgs);
    } catch (final Throwable e) {
        System.err.print(e);
    }
}

From source file:com.splunk.shuttl.archiver.model.BucketTest.java

@Test(expectedExceptions = { FileNotFoundException.class })
public void uriConstructor_initWithFileUriToNonExistingDirectory_throwsFileNotFoundException()
        throws IOException {
    File file = createDirectory();
    assertTrue(file.delete());//from www .j  av  a2s .c  o  m
    new Bucket(file.toURI(), null, null, null);
}

From source file:br.edimarmanica.trinity.extract.Extract.java

private void train(File fPage) throws IOException {
    String sPage = UTF8FileUtil.readStrippedHTML(fPage.toURI());

    TreeMap<Integer, Token> tokensPages = tokeniser.tokenise(sPage).getTokensMap();
    tokensPages.remove(tokensPages.lastKey());
    Text textPage = new Text(fPage, tokensPages.values());

    root.add(textPage);/*from   w  ww.ja v  a  2s .co  m*/
}

From source file:de.qucosa.webapi.v1.FileHandlingService.java

public URI renameFileInTargetFileSpace(String filename, String newname, String qid) throws IOException {
    File sourceFile = new File(new File(documentsPath, qid), filename);
    File targetFile = new File(new File(documentsPath, qid), newname);
    if (!sourceFile.equals(targetFile)) {
        FileUtils.moveFile(sourceFile, targetFile);
    }// w w w  .j  a v a2s  . co  m
    return targetFile.toURI().normalize();
}

From source file:net.sf.maltcms.chromaui.chromatogram2Dviewer.datastructures.annotations.Peak2DXMLAnnotationProvider.java

/**
 *
 * @param l/*  w w  w  . jav  a2 s  .co  m*/
 * @param f
 */
@Override
public void store(List<XYAnnotation> l, File f) {
    MaltcmsAnnotationFactory maf = new MaltcmsAnnotationFactory();
    MaltcmsAnnotation ma = maf.createNewMaltcmsAnnotationType(f.toURI());
    for (XYAnnotation xya : l) {
        if (xya instanceof XYSelectableShapeAnnotation) {
            if (((XYSelectableShapeAnnotation<?>) xya).getT() instanceof Peak2D) {
                XYSelectableShapeAnnotation<Peak2D> xyp = (XYSelectableShapeAnnotation<Peak2D>) xya;
                Peak2D p2 = xyp.getT();
                maf.addPeakAnnotation(ma, getClass().getName(), p2);
            }
        }
    }
    maf.save(ma, f);
}

From source file:com.gzj.tulip.load.vfs.SimpleFileObject.java

@Override
public FileObject getParent() throws MalformedURLException, IOException {
    File parent = file.getParentFile();
    if (parent == null) {
        return null;
    }//from  w  w  w.  j  av a2 s . c  o m
    return fs.resolveFile(parent.toURI().toURL());
}

From source file:com.github.bfour.fpliteraturecollector.service.FileStorageService.java

public Link persist(File localFile, Literature lit) throws IOException {

    String fileName = getFileNameForLiterature(lit);
    fileName += "." + FilenameUtils.getExtension(localFile.getAbsolutePath());
    File file = new File(rootDirectory.getAbsolutePath() + "/" + lit.getID() + "/" + fileName);

    FileUtils.copyFile(localFile, file);

    return new Link(fileName, file.toURI());

}

From source file:com.comcast.video.dawg.show.plugins.RemotePluginManager.java

/**
 * Stores a jar and finds all the plugin classes in that jar
 * @param jarFile The jar file on the server
 * @throws IOException/*from   w  ww. ja  v  a2s . c  o  m*/
 */
public void storePlugin(File jarFile) throws IOException {
    URL jarUrl = jarFile.toURI().toURL();
    URLClassLoader urlcl = new URLClassLoader(new URL[] { jarUrl }, this.getClass().getClassLoader());
    Reflections ref = new Reflections(
            new ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader(urlcl)).addClassLoader(urlcl));
    /** Find all classes in the jar that implement a KeyInputPlugin and add them to our plugin list */
    Set<Class<? extends KeyInputPlugin>> plugins = ref.getSubTypesOf(KeyInputPlugin.class);
    for (Class<? extends KeyInputPlugin> clazz : plugins) {
        try {
            KeyInputPlugin<?> kip = clazz.newInstance();
            PluginConfiguration config = kip.getConfigClass().newInstance();
            PluginAndConfig<KeyInput, ?> pac = new PluginAndConfig(kip, config, jarFile);
            LOGGER.info("Adding plugin class '" + clazz.getName() + "' for remote " + kip.getRemoteType());
            if (this.plugins.containsKey(kip.getRemoteType())) {
                /** Remove the old remote plugin */
                File oldJar = this.plugins.get(kip.getRemoteType()).getJarFile();
                FileUtils.deleteQuietly(oldJar);
            }
            this.plugins.put(kip.getRemoteType(), pac);
            /** Updates the mapping to the UI remote */
            this.remoteManager.addRemoteTypeToRemote(kip.getRemoteUiId(), kip.getRemoteType());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:com.asakusafw.testdriver.DirectIoUtilTest.java

private URL asFileUrl(String name) {
    File f = asFile(name);
    try {/*ww  w . j a v  a 2 s  .  com*/
        return f.toURI().toURL();
    } catch (MalformedURLException e) {
        Assume.assumeNoException(e);
        throw new AssertionError(e);
    }
}