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:projavafx.videoplayer3.VideoPlayer3.java

@Override
public void start(Stage primaryStage) {
    final Label message = new Label("I \u2764 Robots");
    message.setVisible(false);/*  w w w . j a  v  a  2  s .  c  o  m*/

    String workingDir = System.getProperty("user.dir");
    final File f = new File(workingDir, "../media/omgrobots.flv");

    final Media m = new Media(f.toURI().toString());
    m.getMarkers().put("Split", Duration.millis(3000));
    m.getMarkers().put("Join", Duration.millis(9000));

    final MediaPlayer mp = new MediaPlayer(m);

    final MediaView mv1 = new MediaView(mp);
    mv1.setViewport(new Rectangle2D(0, 0, 960 / 2, 540));
    StackPane.setAlignment(mv1, Pos.CENTER_LEFT);

    final MediaView mv2 = new MediaView(mp);
    mv2.setViewport(new Rectangle2D(960 / 2, 0, 960 / 2, 540));
    StackPane.setAlignment(mv2, Pos.CENTER_RIGHT);

    StackPane root = new StackPane();
    root.getChildren().addAll(message, mv1, mv2);
    root.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            mp.seek(Duration.ZERO);
            message.setVisible(false);
        }
    });

    final Scene scene = new Scene(root, 960, 540);
    final URL stylesheet = getClass().getResource("media.css");
    scene.getStylesheets().add(stylesheet.toString());

    primaryStage.setScene(scene);
    primaryStage.setTitle("Video Player 3");
    primaryStage.show();

    mp.setOnMarker(new EventHandler<MediaMarkerEvent>() {

        @Override
        public void handle(final MediaMarkerEvent event) {
            Platform.runLater(new Runnable() {

                @Override
                public void run() {
                    if (event.getMarker().getKey().equals("Split")) {
                        message.setVisible(true);
                        buildSplitTransition(mv1, mv2).play();
                    } else {
                        buildJoinTransition(mv1, mv2).play();
                    }
                }

            });
        }
    });
    mp.play();
}

From source file:com.github.ukase.toolkit.ResourceProvider.java

private String resolvePath(File resources) {
    if (resources != null && resources.isDirectory()) {
        return resources.toURI().toString();
    }/*from   w ww  .j  a  va2s  . c  o m*/
    return null;
}

From source file:com.xruby.debug.DebugCommandLineOptions.java

public List<URL> getClassPathList() {
    StringTokenizer st = new StringTokenizer(classPath, ";");
    List<URL> list = new ArrayList<URL>();

    while (st.hasMoreTokens()) {
        File file = new File(st.nextToken());
        if (file.exists()) {
            try {
                list.add(file.toURI().toURL());
            } catch (MalformedURLException e) {
                // TODO: Handle this exception
            }/*w  w  w .  ja va 2  s. c om*/
        }
    }

    return list;
}

From source file:org.openmhealth.schema.service.FileSystemSchemaFileServiceImpl.java

@Override
public List<SchemaFile> getSchemaFiles(URI baseDirectory) {

    List<SchemaFile> schemaFiles = new ArrayList<>();

    try {/*from  ww w  .  ja v  a  2  s. c o m*/
        File[] namespaceDirectories = new File(baseDirectory).listFiles();

        if (namespaceDirectories == null) {
            return schemaFiles;
        }

        for (File namespaceDirectory : namespaceDirectories) {

            File[] files = namespaceDirectory.listFiles();

            if (files == null) {
                continue;
            }

            for (File file : files) {

                // skip wildcard links, $referenced links are tested automatically
                if (file.toURI().toString().endsWith(".x.json")) {
                    continue;
                }

                JsonSchema jsonSchema = jsonSchemaFactory.getJsonSchema(file.toURI().toString());
                schemaFiles.add(new SchemaFile(file.toURI(), jsonSchema));
            }
        }
    } catch (ProcessingException e) {
        throw new RuntimeException(format("The schema files in directory '%s' can't be loaded.", baseDirectory),
                e);
    }

    return schemaFiles;
}

From source file:com.github.thesmartenergy.sparql.generate.jena.engine.Bnodes.java

public void test(String value) throws Exception {
    URL examplePath = Bnodes.class.getResource("/" + value);
    File exampleDir = new File(examplePath.toURI());

    // read location-mapping
    URI confUri = exampleDir.toURI().resolve("configuration.ttl");
    Model conf = RDFDataMgr.loadModel(confUri.toString());

    // initialize file manager
    FileManager fileManager = FileManager.makeGlobal();
    Locator loc = new LocatorFile(exampleDir.toURI().getPath());
    LocationMapper mapper = new LocationMapper(conf);
    fileManager.addLocator(loc);/* w w  w  .j av a  2 s  . c o m*/
    fileManager.setLocationMapper(mapper);

    String qstring = IOUtils.toString(fileManager.open("query.rqg"), "UTF-8");
    SPARQLGenerateQuery q = (SPARQLGenerateQuery) QueryFactory.create(qstring, SPARQLGenerate.SYNTAX);

    // create generation plan
    PlanFactory factory = new PlanFactory(fileManager);
    RootPlan plan = factory.create(q);
    Model output = plan.exec();

    // write output
    output.write(System.out, "TTL");

    Model expectedOutput = fileManager.loadModel("expected_output.ttl");
    StringWriter sw = new StringWriter();
    expectedOutput.write(sw, "TTL");
    LOG.debug("\n" + sw.toString());

    Assert.assertTrue(output.isIsomorphicWith(expectedOutput));
}

From source file:com.liferay.maven.arquillian.internal.tasks.ToolsClasspathTask.java

@Override
public URLClassLoader execute(MavenWorkingSession session) {

    final Logger log = LoggerFactory.getLogger(ToolsClasspathTask.class);

    final ParsedPomFile pomFile = session.getParsedPomFile();

    LiferayPluginConfiguration configuration = new LiferayPluginConfiguration(pomFile);

    System.setProperty("liferayVersion", configuration.getLiferayVersion());

    File appServerLibGlobalDir = new File(configuration.getAppServerLibGlobalDir());

    File appServerLibPortalDir = new File(configuration.getAppServerLibPortalDir());

    List<URI> liferayToolArchives = new ArrayList<URI>();

    if (appServerLibGlobalDir != null && appServerLibGlobalDir.exists()) {

        // app server global libraries
        Collection<File> appServerLibs = FileUtils.listFiles(appServerLibGlobalDir, new String[] { "jar" },
                true);//  ww w . j  a va2s  .  c om

        for (File file : appServerLibs) {
            liferayToolArchives.add(file.toURI());
        }

        // All Liferay Portal Lib jars
        Collection<File> liferayPortalLibs = FileUtils.listFiles(appServerLibPortalDir, new String[] { "jar" },
                true);

        for (File file : liferayPortalLibs) {
            liferayToolArchives.add(file.toURI());
        }

        // Util jars
        File[] utilJars = Maven.resolver().loadPomFromClassLoaderResource("liferay-tool-deps.xml")
                .importCompileAndRuntimeDependencies().resolve().using(AcceptAllStrategy.INSTANCE).asFile();

        for (int i = 0; i < utilJars.length; i++) {
            liferayToolArchives.add(utilJars[i].toURI());
        }

    }

    log.trace("Jars count in Tools classpath Archive:" + liferayToolArchives.size());

    List<URL> classpathUrls = new ArrayList<URL>();

    try {
        if (!liferayToolArchives.isEmpty()) {

            ListIterator<URI> toolsJarItr = liferayToolArchives.listIterator();
            while (toolsJarItr.hasNext()) {
                URI jarURI = toolsJarItr.next();
                classpathUrls.add(jarURI.toURL());
            }

        }
    } catch (MalformedURLException e) {
        log.error("Error building Tools classpath", e);
    }

    return new URLClassLoader(classpathUrls.toArray(new URL[classpathUrls.size()]), null);
}

From source file:de.flashpixx.rrd_antlr4.generator.CPlugin.java

@Override
protected final File processoutputdirectory(final File p_grammar) {
    return new File(m_grammarbase.toURI().relativize(p_grammar.toURI()).toString());
}

From source file:it.geosolutions.utils.db.Gml2shp.java

public void importGmlIntoShp(File gmlFile, File shpFile) throws Exception {

    FileDataStoreFactorySpi factory = FileDataStoreFinder.getDataStoreFactory("shp");
    Map map = Collections.singletonMap("url", shpFile.toURI().toURL());

    DataStore datastore = factory.createNewDataStore(map);
    GmlImporter.importGml(gmlFile, datastore, forcedInputCrs);
}

From source file:com.anrisoftware.globalpom.textmatch.match.DefaultMatchText.java

/**
 * @see DefaultMatchTextFactory#create(File, Pattern, Charset)
 *///from   w  w  w .ja va  2s .c  o m
@AssistedInject
DefaultMatchText(@Assisted File file, @Assisted Pattern pattern, @Assisted Charset charset) {
    this(file.toURI(), pattern, charset);
}

From source file:$.MqttConfig.java

private MqttConfig() {
        File configFile = new File(DeviceTypeConstants.MQTT_CONFIG_LOCATION);
        if (configFile.exists()) {
            try {
                InputStream propertyStream = configFile.toURI().toURL().openStream();
                Properties properties = new Properties();
                properties.load(propertyStream);
                brokerEndpoint = DeviceTypeUtils
                        .replaceMqttProperty(properties.getProperty(DeviceTypeConstants.BROKER_URL_PROPERTY_KEY));
            } catch (IOException e) {
                log.error("Failed to read the mqtt.properties file" + e);
            }/*from w  ww.  j a v a2  s  .  c  om*/
        }
    }