List of usage examples for java.io File toURI
public URI toURI()
From source file:contrail.correct.TestFlashExtension.java
private void runApp(File input, File output) { InvokeFlash flashInvoker = new InvokeFlash(); InvokeFlash.blockSize = 3;/*from w w w. j a v a2 s. c om*/ String[] args = { "--inputpath=" + input.toURI().toString(), "--outputpath=" + output.toURI().toString(), "--flash_binary=" + flashBinaryPath }; try { flashInvoker.run(args); } catch (Exception exception) { fail("Exception occured:" + exception.getMessage()); } }
From source file:com.all.client.components.MCMediaWrapper.java
public MCMediaWrapper(File file) { this.media = new Media(file.toURI()); String filePath = null;//from w ww.ja v a 2s . c o m if (Environment.isMac()) { filePath = file.toURI().toString(); } else { String shortPath = ShortFilePathNative.getShortPath(file); filePath = "file:/" + shortPath.replaceAll("\\\\", "/"); log.debug("media file path " + filePath); } try { for (int i = 0; i < 100 && !loaded; i++) { if (media != null) { loaded = true; break; } Thread.sleep(10); if (media.getDuration() != 0.0) { loaded = true; } } } catch (InterruptedException e) { error = true; loaded = true; } }
From source file:dk.clanie.bitcoin.client.response.ResponseSerializationTest.java
/** * Reveals a bug in Jackson./*from w w w . j a v a 2 s.c om*/ * * @JsonUnwrapped conflicts with @JsonAnySetter/@JsonAnyGetter. * See https://github.com/FasterXML/jackson-annotations/issues/10 * <p> * Some serialization tests have been disabled by prefixing some * of the sample file names with an underscore. * <p> * When the Jackson bug has been fixed remove this test and it's * resource file "_DOUBLE_UNWRAP.json" and re-enable other tests * by removing the underscore prefix from sample file names. * * @throws Exception */ @Test @Ignore // TODO Remove when Jackson has been fixed. public void testDoubleUnwrapped() throws Exception { File file = new File("src/test/resources/sampleResponse/_DOUBLE_UNWRAP.json"); String jsonSample = IOUtils.toString(file.toURI()); ListUnspentResult obj = objectMapper.readValue(jsonSample, ListUnspentResult.class); String roundtrippedJson = objectMapper.writeValueAsString(obj); System.out.println(roundtrippedJson); assertThat("json -> obj -> json roundtrip serialization failed for " + file.getName() + ".", roundtrippedJson, equalTo(jsonSample)); }
From source file:com.googlecode.jweb1t.IndexCreator.java
private void write(final File outputFile) throws IOException { PrintWriter writer = null;/*ww w . j a v a2 s . c o m*/ try { writer = new PrintWriter(new FileWriter(outputFile)); for (final String ch : map.keySet()) { final List<File> fileList = map.get(ch); writer.print(ch); for (final File file : fileList) { // store only the path relative to the index file final String relative = baseDir.toURI().relativize(file.toURI()).getPath(); writer.print("\t" + relative); } writer.print("\n"); } writer.flush(); } finally { IOUtils.closeQuietly(writer); } }
From source file:com.eviware.soapui.plugins.JarClassLoader.java
public JarClassLoader(File jarFile, ClassLoader parent, Collection<JarClassLoader> dependencyClassLoaders) throws IOException { super(new URL[] { jarFile.toURI().toURL() }, null); this.parent = parent; this.dependencyClassLoaders = dependencyClassLoaders; JarFile file = new JarFile(jarFile); addLibrariesIn(file);/*from w w w. j a va 2 s . com*/ addScriptsIn(file); }
From source file:com.mirth.connect.plugins.directoryresource.DirectoryResourceServlet.java
@Override public List<String> getLibraries(String resourceId) { try {//from ww w . jav a 2 s.com DirectoryResourceProperties props = null; ResourcePropertiesList resources = serializer.deserialize(configurationController.getResources(), ResourcePropertiesList.class); for (ResourceProperties resource : resources.getList()) { if (resource instanceof DirectoryResourceProperties && resource.getId().equals(resourceId)) { props = (DirectoryResourceProperties) resource; break; } } List<String> libraries = new ArrayList<String>(); if (props != null) { List<URL> urls = contextFactoryController.getLibraries(props.getId()); if (StringUtils.isNotBlank(props.getDirectory())) { File directory = new File(props.getDirectory()); for (URL url : urls) { libraries.add(StringUtils.removeStartIgnoreCase(url.toString(), directory.toURI().toURL().toString())); } } else { for (URL url : urls) { libraries.add(url.toString()); } } Collections.sort(libraries); } return libraries; } catch (MirthApiException e) { throw e; } catch (Exception e) { throw new MirthApiException(e); } }
From source file:net.minecraftforge.fml.common.asm.transformers.MarkerTransformer.java
private void readMapFile(String rulesFile) throws IOException { File file = new File(rulesFile); URL rulesResource;//from ww w . ja va 2 s . c o m if (file.exists()) { rulesResource = file.toURI().toURL(); } else { rulesResource = Resources.getResource(rulesFile); } Resources.readLines(rulesResource, Charsets.UTF_8, new LineProcessor<Void>() { @Override public Void getResult() { return null; } @Override public boolean processLine(String input) throws IOException { String line = Iterables.getFirst(Splitter.on('#').limit(2).split(input), "").trim(); if (line.length() == 0) { return true; } List<String> parts = Lists.newArrayList(Splitter.on(" ").trimResults().split(line)); if (parts.size() != 2) { throw new RuntimeException("Invalid config file line " + input); } List<String> markerInterfaces = Lists .newArrayList(Splitter.on(",").trimResults().split(parts.get(1))); for (String marker : markerInterfaces) { markers.put(parts.get(0), marker); } return true; } }); }
From source file:org.geoserver.wps.executor.util.DefaultClusterFilePublisherURLMangler.java
/** * Gets the publishing url./*from ww w .j a va2s .c o m*/ * * @param file the file * @return the publishing url * @throws Exception the exception */ @Override public String getPublishingURL(File file, String baseURL) throws Exception { // relativize to temp dir directory GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class); String path = loader.getBaseDirectory().toURI().relativize(file.toURI()).getPath(); return ResponseUtils.buildURL(baseURL, path, null, URLType.RESOURCE); }
From source file:architecture.ee.jdbc.sqlquery.factory.impl.AbstractSqlQueryFactory.java
public boolean isFileDeployed(File file) { return deployments.containsKey(file.toURI()); }
From source file:com.shopzilla.hadoop.repl.commands.util.ClusterStateManager.java
private void importHDFSDirectory(final Path hdfsRoot, final File localRoot, final File file) throws IOException { final Path path = new Path(hdfsRoot, File.separator + localRoot.toURI().relativize(file.toURI()).getPath()); if (file.isDirectory()) { fs.mkdirs(path);/*from ww w. ja va 2 s. com*/ fs.makeQualified(path); for (final File child : file.listFiles()) { importHDFSDirectory(hdfsRoot, localRoot, child); } } else { fs.copyFromLocalFile(false, true, new Path(file.getAbsolutePath()), path); fs.makeQualified(path); } }