List of usage examples for java.io File toURI
public URI toURI()
From source file:com.izforge.izpack.integration.UninstallHelper.java
/** * Helper to create an isolated class loader using only those classes in the specified uninstall jar. * * @param uninstallJar the uninstaller jar * @return a new class loader//from ww w . j a va2s. co m * @throws MalformedURLException */ private static ClassLoader getClassLoader(File uninstallJar) throws MalformedURLException { // create an isolated class loader for loading classes and resources return new URLClassLoader(new URL[] { uninstallJar.toURI().toURL() }, null); }
From source file:jp.terasoluna.fw.batch.unit.util.ClassLoaderUtils.java
/** * <pre>// w w w . j a v a 2 s. com * ????????????? * ??????? * * ???? * ???????????? * {@link #resetClassLoader()}??????? * * ?????????warn??? * </pre> * * @param file ? */ public static void addClassPath(File file) { Assert.notNull(file); try { if (file.exists()) { addClassPath(file.toURI().toURL()); } else { LOG.warn(file + " is not found."); } } catch (MalformedURLException e) { // ????????? LOG.warn(file + " is illegal.", e); } }
From source file:com.geewhiz.pacify.test.TestUtil.java
public static URL getURLForFile(File file) { try {// w w w .ja v a2 s.com return file.toURI().toURL(); } catch (MalformedURLException e) { Assert.fail(); } throw new RuntimeException("Shouldn't reach this code!"); }
From source file:io.specto.hoverfly.junit.HoverflyRuleUtils.java
static URI createFileRelativeToClasspath(String resourceName) throws IOException { final File file = Paths.get(new File("").getAbsolutePath(), resourceName).toFile(); file.mkdirs();/* w w w . j av a 2 s . c om*/ if (!file.exists()) { file.delete(); } file.createNewFile(); return file.toURI(); }
From source file:com.chinamobile.bcbsp.util.ClassLoaderUtil.java
/** * Add Ext class path//from w ww . j a v a 2 s.c o m * * @param dirOrJar The class path */ public static void addExtClassPath(File dirOrJar) { try { addURL2ExtClassLoader(dirOrJar.toURI().toURL()); } catch (MalformedURLException e) { LOG.error("[addExtClassPath]", e); } }
From source file:gov.va.vinci.leo.CommandLineClient.java
/** * Parse the groovy config file, and return the reader object. This must be a BaseLeoCollectionReader. * * @param config the groovy config file to slurp * @return the reader defined in the groovy config. * @throws MalformedURLException if the configuration file url that was set is invalid. *//* w w w.ja v a 2 s. c o m*/ public static BaseLeoCollectionReader getReader(File config) throws MalformedURLException { ConfigSlurper configSlurper = new ConfigSlurper(); ConfigObject configObject = configSlurper.parse(config.toURI().toURL()); if (configObject.get("reader") != null) { return (BaseLeoCollectionReader) configObject.get("reader"); } return null; }
From source file:io.fluo.stress.TrieMapRedIT.java
static void load(int nodeSize, File fluoPropsFile, File input) throws Exception { int ret = ToolRunner.run(new Load(), new String[] { "-D", "mapred.job.tracker=local", "-D", "fs.defaultFS=file:///", fluoPropsFile.getAbsolutePath(), input.toURI().toString() }); Assert.assertEquals(0, ret);//from w w w. j ava 2s .com }
From source file:com.chinamobile.bcbsp.util.ClassLoaderUtil.java
/** * Add class path/*w ww . ja v a2 s . c o m*/ * * @param dirOrJar The class path */ public static void addClassPath(File dirOrJar) { try { addURL2SystemClassLoader(dirOrJar.toURI().toURL()); } catch (MalformedURLException e) { LOG.error("[addClassPath]", e); } }
From source file:com.googlecode.jsonschema2pojo.cli.Jsonschema2Pojo.java
/** * Reads the contents of the given source and initiates schema generation. * //from w w w .j a va 2 s . c o m * @param config * the configuration options (including source and target paths, * and other behavioural options) that will control code * generation * @throws FileNotFoundException * if the source path is not found * @throws IOException * if the application is unable to read data from the source */ public static void generate(GenerationConfig config) throws FileNotFoundException, IOException { Annotator annotator = getAnnotator(config); SchemaMapper mapper = new SchemaMapper(new RuleFactory(config, annotator, new SchemaStore()), new SchemaGenerator()); JCodeModel codeModel = new JCodeModel(); if (config.isRemoveOldOutput()) { removeOldOutput(config.getTargetDirectory()); } for (Iterator<File> sources = config.getSource(); sources.hasNext();) { File source = sources.next(); if (source.isDirectory()) { List<File> schemaFiles = Arrays.asList(source.listFiles()); Collections.sort(schemaFiles); for (File child : schemaFiles) { if (child.isFile()) { mapper.generate(codeModel, getNodeName(child), defaultString(config.getTargetPackage()), child.toURI().toURL()); } } } else { mapper.generate(codeModel, getNodeName(source), defaultString(config.getTargetPackage()), source.toURI().toURL()); } } if (config.getTargetDirectory().exists() || config.getTargetDirectory().mkdirs()) { codeModel.build(config.getTargetDirectory(), new NullPrintStream()); } else { throw new GenerationException( "Could not create or access target directory " + config.getTargetDirectory().getAbsolutePath()); } }
From source file:com.textocat.textokit.commons.util.CorpusUtils.java
/** * @param baseDir//from w w w .ja v a 2 s . com * @return function that returns the URI of an arg File relative to the URI * of the given baseDir. * @see #relativePathFunction(File) */ public static Function<File, URI> relativeURIFunction(final File baseDir) { return new Function<File, URI>() { private URI baseURI = baseDir.toURI(); @Override public URI apply(File arg) { URI relURI = baseURI.relativize(arg.toURI()); try { return new URI("file", relURI.getPath(), null); } catch (URISyntaxException e) { throw new IllegalStateException(e); } } }; }