List of usage examples for java.io File toURI
public URI toURI()
From source file:com.espertech.esperio.db.EsperIODBAdapterPlugin.java
private URL resolveURL(String config) throws Exception { URL url = this.getClass().getClassLoader().getResource(config); if (url != null) { return url; }// w w w .j av a2 s . c o m url = Thread.currentThread().getContextClassLoader().getResource(config); if (url != null) { return url; } File file = new File(config); if (!file.isAbsolute()) { String espereeBase = System.getProperty("esperee.base"); file = new File(espereeBase, config); } if (file.exists()) { return file.toURI().toURL(); } return new URL(config); }
From source file:com.laxser.blitz.lama.core.LamaDaoProcessor.java
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (logger.isInfoEnabled()) { logger.info("[jade] starting ..."); }//from w w w . j ava 2 s.c o m final List<ResourceRef> resources; try { resources = BlitzScanner.getInstance().getJarOrClassesFolderResources(); } catch (IOException e) { throw new ApplicationContextException("error on getJarResources/getClassesFolderResources", e); } List<String> urls = new LinkedList<String>(); for (ResourceRef resourceInfo : resources) { if (resourceInfo.hasModifier("dao") || resourceInfo.hasModifier("DAO")) { try { Resource resource = resourceInfo.getResource(); File resourceFile = resource.getFile(); if (resourceFile.isFile()) { urls.add("jar:file:" + resourceFile.toURI().getPath() + ResourceUtils.JAR_URL_SEPARATOR); } else if (resourceFile.isDirectory()) { urls.add(resourceFile.toURI().toString()); } } catch (IOException e) { throw new ApplicationContextException("error on resource.getFile", e); } } } if (logger.isInfoEnabled()) { logger.info("[jade] found " + urls.size() + " jade urls: " + urls); } if (urls.size() > 0) { LamaDaoComponentProvider provider = new LamaDaoComponentProvider(true); if (filters != null) { for (TypeFilter excludeFilter : filters) { provider.addExcludeFilter(excludeFilter); } } final DataAccessProvider dataAccessProvider = createJdbcTemplateDataAccessProvider(); Set<String> daoClassNames = new HashSet<String>(); for (String url : urls) { if (logger.isInfoEnabled()) { logger.info("[jade] call 'jade/find'"); } Set<BeanDefinition> dfs = provider.findCandidateComponents(url); if (logger.isInfoEnabled()) { logger.info("[jade] found " + dfs.size()// + " beanDefinition from '" + url + "'"); } for (BeanDefinition beanDefinition : dfs) { String daoClassName = beanDefinition.getBeanClassName(); if (daoClassNames.contains(daoClassName)) { if (logger.isDebugEnabled()) { logger.debug("[jade] ignored replicated jade dao class: " + daoClassName + " [" + url + "]"); } continue; } daoClassNames.add(daoClassName); MutablePropertyValues propertyValues = beanDefinition.getPropertyValues(); propertyValues.addPropertyValue("dataAccessProvider", dataAccessProvider); propertyValues.addPropertyValue("daoClass", daoClassName); ScannedGenericBeanDefinition scannedBeanDefinition = (ScannedGenericBeanDefinition) beanDefinition; scannedBeanDefinition.setPropertyValues(propertyValues); scannedBeanDefinition.setBeanClass(LamaDaoFactoryBean.class); DefaultListableBeanFactory defaultBeanFactory = (DefaultListableBeanFactory) beanFactory; defaultBeanFactory.registerBeanDefinition(daoClassName, beanDefinition); if (logger.isDebugEnabled()) { logger.debug("[jade] register jade dao bean: " + daoClassName); } } } } if (logger.isInfoEnabled()) { logger.info("[jade] exits"); } }
From source file:ch.kostceco.bento.sipval.service.impl.ConfigurationServiceImpl.java
@Override public String getPathOfDroidSignatureFile() throws MalformedURLException { String pathSignature = getPathToDroidSignatureFile(); File fileSigfile = new File(pathSignature); URL urlSigfile = fileSigfile.toURI().toURL(); String result = urlSigfile.getFile(); return result; }
From source file:com.heimuheimu.runningtask.task.service.support.SimpleURLClassLoaderFactory.java
private URL getURL(String localFilePath) { File file = new File(localFilePath); if (!file.exists()) { throw new IllegalArgumentException("Local file path is not exist: `" + localFilePath + "`"); }/*from ww w . ja v a2 s . c o m*/ try { return file.toURI().toURL(); } catch (MalformedURLException e) { throw new IllegalArgumentException("Illegal local file path: `" + localFilePath + "`", e); } }
From source file:com.shopzilla.hadoop.testing.hdfs.DFSCluster.java
public void importHDFSDirectory(final Path hdfsRoot, final File file) throws IOException { final Path path = new Path(hdfsRoot, File.separator + localRoot.toURI().relativize(file.toURI()).getPath()); if (file.isDirectory()) { getFileSystem().mkdirs(path);//w w w .j av a 2 s .co m getFileSystem().makeQualified(path); for (final File child : file.listFiles()) { importHDFSDirectory(hdfsRoot, child); } } else { getFileSystem().copyFromLocalFile(false, true, new Path(file.getAbsolutePath()), path); getFileSystem().makeQualified(path); } }
From source file:com.terradue.dsi.UploadAppliance.java
private void addToZip(ZipOutputStream os, URI base, File file) throws IOException { String name = base.relativize(file.toURI()).getPath(); if (file.isDirectory()) { name = name.endsWith("/") ? name : name + "/"; }/*from www .j ava 2 s . c o m*/ ZipEntry entry = new ZipEntry(name); entry.setSize(file.length()); os.putNextEntry(entry); if (file.isDirectory()) { logger.info(" creating: {}", name); for (File kid : file.listFiles()) { addToZip(os, base, kid); } } else { logger.info("deflating: {}", name); FileInputStream input = new FileInputStream(file); long compressed = 0; int length = 0; byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; try { while (EOF != (length = input.read(buffer))) { os.write(buffer, 0, length); compressed += length; System.out.printf("%s%%\r", ((compressed * 100) / file.length())); } } finally { closeQuietly(input); } } os.closeEntry(); }
From source file:com.flipkart.aesop.runtime.impl.admin.RuntimeConfigServiceImpl.java
/** * Interface method implementation// w w w. j av a 2s . c o m * @see com.flipkart.aesop.runtime.spi.admin.RuntimeConfigService#addRuntimeConfigPath(java.io.File, com.linkedin.databus2.core.container.netty.ServerContainer) */ public void addRuntimeConfigPath(File runtimeFile, ServerContainer runtime) { if (this.configURItoRuntimeName.get(runtimeFile.toURI()) == null) { this.configURItoRuntimeName.put(runtimeFile.toURI(), new LinkedList<ServerContainer>()); } this.configURItoRuntimeName.get(runtimeFile.toURI()).add(runtime); }
From source file:com.smash.revolance.ui.explorer.Explorer.java
private Application instanciateApplication(File applicationJar, String fullClassName) throws ClassNotFoundException, MalformedURLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { ClassLoader loader = new JarClassLoader(applicationJar.toURI().toURL()); if (loader == null) { loader = Thread.currentThread().getContextClassLoader(); }//from w w w . j a v a 2 s . c om Class<?> applicationClass = loader.loadClass(fullClassName); return (Application) applicationClass.getDeclaredConstructor().newInstance(); }