List of usage examples for java.io File toURI
public URI toURI()
From source file:Main.java
@Override public void start(Stage primaryStage) { final Label markerText = new Label(); StackPane.setAlignment(markerText, Pos.TOP_CENTER); String workingDir = System.getProperty("user.dir"); final File f = new File(workingDir, "../media/omgrobots.flv"); final Media m = new Media(f.toURI().toString()); final ObservableMap<String, Duration> markers = m.getMarkers(); markers.put("Robot Finds Wall", Duration.millis(3100)); markers.put("Then Finds the Green Line", Duration.millis(5600)); markers.put("Robot Grabs Sled", Duration.millis(8000)); markers.put("And Heads for Home", Duration.millis(11500)); final MediaPlayer mp = new MediaPlayer(m); mp.setOnMarker(new EventHandler<MediaMarkerEvent>() { @Override/*from ww w . java 2 s .c o m*/ public void handle(final MediaMarkerEvent event) { Platform.runLater(new Runnable() { @Override public void run() { markerText.setText(event.getMarker().getKey()); } }); } }); final MediaView mv = new MediaView(mp); final StackPane root = new StackPane(); root.getChildren().addAll(mv, markerText); root.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { mp.seek(Duration.ZERO); markerText.setText(""); } }); 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 2"); primaryStage.show(); mp.play(); }
From source file:de.mendelson.comm.as2.client.HTMLPanel.java
/**Sets a new page to the viewer *///from www .j av a 2 s . c o m public void setPage(File htmlFile) { try { this.jEditorPane.setPage(htmlFile.toURI().toURL()); } catch (Exception e) { //nop } }
From source file:br.msf.commons.util.IOUtils.java
public static String getRelativePath(final File base, final File child) { ArgumentUtils.rejectIfAnyNull(base, child); return base.toURI().relativize(child.toURI()).getPath(); }
From source file:dtool.dub.BundlePath.java
public BundlePath(File path) { assertTrue(BundlePath.isValidBundlePath(path)); this.path = new File(path.toURI().normalize()); }
From source file:com.twitter.distributedlog.service.config.DefaultStreamConfigProvider.java
public DefaultStreamConfigProvider(String configFilePath, ScheduledExecutorService executorService, int reloadPeriod, TimeUnit reloadUnit) throws ConfigurationException { try {/*from w w w. j av a2 s. c o m*/ File configFile = new File(configFilePath); FileConfigurationBuilder properties = new PropertiesConfigurationBuilder(configFile.toURI().toURL()); ConcurrentConstConfiguration defaultConf = new ConcurrentConstConfiguration( new DistributedLogConfiguration()); DynamicDistributedLogConfiguration conf = new DynamicDistributedLogConfiguration(defaultConf); List<FileConfigurationBuilder> fileConfigBuilders = Lists.newArrayList(properties); confSub = new ConfigurationSubscription(conf, fileConfigBuilders, executorService, reloadPeriod, reloadUnit); this.dynConf = Optional.of(conf); } catch (MalformedURLException ex) { throw new ConfigurationException(ex); } }
From source file:org.jvoicexml.demo.mmi.simpledemo.SimpleMmiDemo.java
/** * Executes a session with a predefindedVoiceXML document. * //w w w.ja v a 2s .c o m * @throws URISyntaxException * @throws JAXBException * @throws IOException * @throws ClientProtocolException */ private void call() throws URISyntaxException, JAXBException, IOException, ClientProtocolException { final String context = UUID.randomUUID().toString(); int requestId = 4242; final Mmi mmi = new Mmi(); final StartRequest start = new StartRequest(); mmi.setStartRequest(start); final URI source = new URI("http://localhost:9092"); start.setSource(source.toString()); final URI target = new URI("http://localhost:9090"); start.setTarget(target.toString()); start.setContext(context); start.setRequestId(Integer.toString(requestId)); // final File file = new File("simpleexample.vxml"); final File file = new File("simpleexample-de.vxml"); final URI example = file.toURI(); start.setContentURL(example); send(mmi, target); }
From source file:com.btmatthews.leabharlann.service.impl.FileImportSource.java
/** * Perform a depth first traversal of the directory tree with a root at {@code current} * processing each file discovered by invoking {@code callback}. * root is a directory a depth first traversal of the directory tree is preformed * processing each file discovered./*w w w .ja v a 2 s. c o m*/ * * @param current The root directory. * @param callback The callback used to process the files. * @throws Exception If there was an error. */ private void processDirectory(final File current, final ImportCallback callback) throws Exception { for (final File child : current.listFiles()) { final String path = File.separator + file.toURI().relativize(child.toURI()).getPath(); if (child.isDirectory()) { callback.directory(path); processDirectory(child, callback); } else { final byte[] data = FileUtils.readFileToByteArray(child); callback.file(path, child.lastModified(), data); } } }
From source file:com.baomidou.framework.spring.SWPropertyPlaceholderConfigurer.java
/** * Java.exe-Dsw.home=D:/development?.//from ww w . ja va 2 s . c o m * * spring? <property name="swDeployConfigPathKey" value="sw.home"/>. * * @param propertiesPath * JVM?-Dsw.home=D:/developmentkey, ?sw.home */ public void setSwDeployConfigPathKey(String propertiesPath) { String configFilePath = System.getProperty(propertiesPath); if (configFilePath == null) throw new IllegalArgumentException(propertiesPath + "null, ?java.exe?, ?-D" + propertiesPath + "=D:/xxx"); try { // File file = new File(configFilePath); if (!file.exists() || !file.isDirectory()) throw new IllegalArgumentException(propertiesPath + "" + configFilePath + ", ???"); // File[] listPropertiesFiles = file.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { if (name.endsWith(PROPERTIES_SUFFX)) { return true; } return false; } }); // UrlResource? List<UrlResource> listResource = null; if (listPropertiesFiles != null && listPropertiesFiles.length > 0) { listResource = new ArrayList<UrlResource>(); for (File propertiesFile : listPropertiesFiles) { URI uri = propertiesFile.toURI(); UrlResource urlResource = new UrlResource(uri); listResource.add(urlResource); } } // if (listResource != null) { this.setLocations((Resource[]) listResource.toArray(new UrlResource[listResource.size()])); } } catch (Exception e) { throw new IllegalArgumentException(e); } }
From source file:com.haulmont.cuba.core.sys.AbstractAppContextLoader.java
protected void replaceLocationsFromConf(String[] locations) { String confDirProp = AppContext.getProperty("cuba.confDir"); if (confDirProp == null) throw new IllegalStateException("cuba.confDir app property is not set"); File confDir = new File(confDirProp); for (int i = 0; i < locations.length; i++) { String location = locations[i]; if (ResourceUtils.isUrl(location)) continue; if (location.startsWith("/")) location = location.substring(1); File file = new File(confDir, location); if (file.exists()) { locations[i] = file.toURI().toString(); }//w w w .j a va 2 s.c o m } }
From source file:net.geoprism.data.LocalEndpoint.java
private List<String> listFiles(String prefix) { LinkedList<String> paths = new LinkedList<String>(); FilenameFilter filter = new FilenameFilter() { @Override//from ww w. j a v a 2s. co m public boolean accept(File dir, String name) { return name.endsWith(".xml.gz"); } }; File directory = new File(this.root, prefix); File[] files = directory.listFiles(filter); if (files != null) { for (File file : files) { paths.add(this.root.toURI().relativize(file.toURI()).getPath()); } } return paths; }