List of usage examples for java.io File toURI
public URI toURI()
From source file:com.twitter.distributedlog.config.DynamicConfigurationFactory.java
public synchronized Optional<DynamicDistributedLogConfiguration> getDynamicConfiguration(String configPath, ConcurrentBaseConfiguration defaultConf) throws ConfigurationException { Preconditions.checkNotNull(configPath); try {/* www.j a v a2 s .c o m*/ if (!dynamicConfigs.containsKey(configPath)) { File configFile = new File(configPath); FileConfigurationBuilder properties = new PropertiesConfigurationBuilder( configFile.toURI().toURL()); DynamicDistributedLogConfiguration dynConf = new DynamicDistributedLogConfiguration(defaultConf); List<FileConfigurationBuilder> fileConfigBuilders = Lists.newArrayList(properties); ConfigurationSubscription subscription = new ConfigurationSubscription(dynConf, fileConfigBuilders, executorService, reloadPeriod, reloadUnit); subscriptions.add(subscription); dynamicConfigs.put(configPath, dynConf); LOG.info("Loaded dynamic configuration at {}", configPath); } return Optional.of(dynamicConfigs.get(configPath)); } catch (MalformedURLException ex) { throw new ConfigurationException(ex); } }
From source file:de.xirp.plugin.PluginManager.java
/** * Gets the URLs of all jars which are located exactly at the * given directory path/* w ww . j a va 2 s.c o m*/ * * @param path * the path to get the jar URLs from * @return a list of URLs of the jars */ private static List<URL> getJarURLsFromPath(String path) { File libs = new File(path); File[] jars = libs.listFiles(new FilenameFilter() { public boolean accept(@SuppressWarnings("unused") File dir, String name) { return name.endsWith(".jar"); //$NON-NLS-1$ } }); if (jars != null) { ArrayList<URL> urls = new ArrayList<URL>(jars.length); for (File jar : jars) { try { urls.add(jar.toURI().toURL()); } catch (MalformedURLException e) { logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$ } } return urls; } return new ArrayList<URL>(); }
From source file:com.splunk.shuttl.archiver.model.BucketTest.java
public void getDirectory_initWithFileUri_getDirectory() throws IOException { File file = createDirectory(); Bucket bucketWithFileUri = new Bucket(file.toURI(), null, null, null); assertEquals(file.getAbsolutePath(), bucketWithFileUri.getDirectory().getAbsolutePath()); }
From source file:com.icesoft.jsfmeta.MetadataXmlParser.java
public FacesConfigBean parse(File file) throws IOException, SAXException { return parse(file.toURI().toURL(), new FacesConfigBean()); }
From source file:com.sinosoft.one.mvc.scanning.vfs.SimpleFileObject.java
public FileObject getParent() throws MalformedURLException, IOException { File parent = file.getParentFile(); if (parent == null) { return null; }// w w w . j a v a 2s .co m return fs.resolveFile(parent.toURI().toURL()); }
From source file:br.com.caelum.jstestrunner.JavascriptTestSuite.java
/** * Creates the suite with all detected Javascript tests. * * @param framework Javascript test framework adapter * @see {@link JavascriptTestFramework}/* ww w . ja va2 s . com*/ */ public JavascriptTestSuite(JavascriptTestFramework framework) { this.framework = framework; this.setName(getSuiteName()); File[] testPages = findTestPages(); if (LOG.isInfoEnabled()) { logTestPages(testPages); } WebClient client = createWebClient(); for (File page : testPages) { HtmlPage htmlPage; try { htmlPage = client.getPage(page.toURI().toURL()); } catch (FailingHttpStatusCodeException | IOException e) { throw new RuntimeException("Error running page " + page.getAbsolutePath(), e); } addTestsInPageToSuite(htmlPage); } }
From source file:de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtilsTest.java
@Test public void testWithSpace() throws Exception { File dir = workspace.newFolder("this is a test"); File file = new File(dir, "this is a file name.extension with spaces"); System.out.println("Original: " + file); System.out.println("Original (URL): " + file.toURI().toURL()); File asFile = ResourceUtils.getUrlAsFile(file.toURI().toURL(), false); System.out.println("As file: " + asFile.getPath()); assertEquals("this is a file name", FilenameUtils.getBaseName(asFile.getPath())); assertEquals("extension with spaces", FilenameUtils.getExtension(asFile.getPath())); }
From source file:net.ostis.scpdev.debug.ui.model.PMConsoleLineTracker.java
@Override // /*from www . j a v a2s. c o m*/ public void lineAppended(IRegion line) { // int lineOffset = line.getOffset(); // int lineLength = line.getLength(); try { String text = console.getDocument().get(lineOffset, lineLength); Matcher errorMatcher = errorLinePattern.matcher(text); if (errorMatcher.matches()) { String fileName = errorMatcher.group(1); String lineNumber = errorMatcher.group(2); int fileStart = 1; // The beginning of the line, "File " // hyperlink if we found something if (fileName != null) { int num = -1; try { num = lineNumber != null ? Integer.parseInt(lineNumber) : 0; } catch (NumberFormatException e) { num = 0; } IHyperlink link = null; File file = new File(fileName); IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(file.toURI()); if (files.length > 0 && files[0].exists()) { link = new FileLink(files[0], null, -1, -1, num); } else { // files outside of the workspace // skip } if (link != null) console.addLink(link, lineOffset + fileStart, lineLength - fileStart); } } } catch (BadLocationException e) { log.error("Unexpected exceptin", e); } }
From source file:it.scoppelletti.programmerpower.security.DefaultRoleManager.java
/** * Inizializzazione./* ww w.j av a 2s.c o m*/ */ public void afterPropertiesSet() throws Exception { File dir; URL[] urls = new URL[1]; dir = SharedDataDirectory.getInstance().initResourceDirectory(DefaultRoleManager.class); urls[0] = dir.toURI().toURL(); myLoader = new URLClassLoader(urls); }
From source file:br.com.uol.runas.classloader.JarClassLoader.java
private URL pathToUrl(String path) throws MalformedURLException { try {//from w w w.j a v a2s.co m final URL url = new URL(path); if (url.getProtocol().equals("jar")) { return url; } return new URL(transformToJarSpec(path)); } catch (MalformedURLException e) { final File file = new File(path); if (file.isDirectory()) { return file.toURI().toURL(); } return new URL(transformToJarSpec(file.toURI().toString())); } }