List of usage examples for java.io File toURI
public URI toURI()
From source file:de.uni_hildesheim.sse.easy.ant.modelcopy.ModelCopy.java
/** * Starts the copy process./*from w w w. j a va 2 s. c om*/ * @throws ModelManagementException If IVML files could not be parsed * @throws IOException If files could not be copied. */ private void copy() throws ModelManagementException, IOException { // Initialize loadProject(getSourceFolder(), getMainProject()); Collection<File> originalFiles = FileUtils.listFiles(getSourceFolder(), new EASyModelFilter(), TrueFileFilter.INSTANCE); // Copy all files for (File file : originalFiles) { String relativeFileName = getSourceFolder().toURI().relativize(file.toURI()).getPath(); debugMessage("Processing: " + relativeFileName); File copyDestination = new File(getDestinationFolder(), relativeFileName); if (!copyDestination.exists()) { File destFolder = copyDestination.getParentFile(); destFolder.mkdirs(); if (!relativeFileName.toLowerCase().endsWith(CONFIG_FILE_EXTENSION)) { FileUtils.copyFile(file, copyDestination, false); } else { handleConfigFile(relativeFileName, destFolder); } } } }
From source file:test.com.azaptree.services.spring.application.SpringApplicationServiceTest.java
@Test public void testGenerateXSD() throws JAXBException, IOException { final JAXBContext jc = JAXBContext .newInstance(com.azaptree.services.spring.application.config.SpringApplicationService.class); jc.generateSchema(new SchemaOutputResolver() { @Override//from w ww . j av a 2 s.c o m public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException { File file = new File("target", suggestedFileName); StreamResult result = new StreamResult(file); result.setSystemId(file.toURI().toURL().toString()); return result; } }); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); jc.generateSchema(new SchemaOutputResolver() { @Override public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException { StreamResult result = new StreamResult(bos); result.setSystemId(""); return result; } }); System.out.println(bos.toString()); }
From source file:meme.singularsyntax.mojo.JavaflowEnhanceMojo.java
@SuppressWarnings("unchecked") private void prepareClasspath() throws MojoExecutionException { List<String> runtimeClasspathElements = null; URLClassLoader classLoader = null; try {//from w w w .j av a 2 s . c o m runtimeClasspathElements = project.getCompileClasspathElements(); URL[] runtimeUrls = new URL[runtimeClasspathElements.size()]; for (int ii = 0; ii < runtimeClasspathElements.size(); ii++) { String element = runtimeClasspathElements.get(ii); File elementFile = new File(element); runtimeUrls[ii] = elementFile.toURI().toURL(); } classLoader = new URLClassLoader(runtimeUrls, Thread.currentThread().getContextClassLoader()); Thread.currentThread().setContextClassLoader(classLoader); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException(e.getMessage()); } catch (MalformedURLException e) { throw new MojoExecutionException(e.getMessage()); } }
From source file:com.dtolabs.rundeck.core.common.impl.TestURLFileUpdater.java
/** * Test use of file: url/* w w w . j ava 2s .co m*/ */ public void testUpdateFileUrl() throws Exception { final File file = new File("src/test/resources/com/dtolabs/rundeck/core/common/test-nodes1.xml"); URLFileUpdater updater = new URLFileUpdater(file.toURI().toURL(), null, -1, null, null, false, null, null); File tempfile = File.createTempFile("test", ".yaml"); tempfile.deleteOnExit(); updater.updateFile(tempfile); assertTrue(tempfile.isFile()); assertEquals(file.length(), tempfile.length()); }
From source file:dtool.dub.DubBundle.java
public File relativizePathToImportFolder(File path) { ArrayList<File> importFolders = getEffectiveImportFolders_AbsolutePath(); for (File importFolderPath : importFolders) { if (path.getPath().startsWith(importFolderPath.getPath())) { return new File(importFolderPath.toURI().relativize(path.toURI())); }/*w w w .j a va 2 s . c om*/ } return null; }
From source file:io.mindmaps.migration.csv.CSVDataMigratorTest.java
private CSVParser parser(String fileName) { File file = new File(CSVSchemaMigratorTest.class.getClassLoader().getResource(fileName).getPath()); CSVParser csvParser = null;/*from w w w . j av a 2 s . c o m*/ try { csvParser = CSVParser.parse(file.toURI().toURL(), StandardCharsets.UTF_8, CSVFormat.DEFAULT.withHeader()); } catch (IOException e) { e.printStackTrace(); } return csvParser; }
From source file:org.openmhealth.schema.service.FileSystemDataFileServiceImpl.java
@Override public List<DataFile> getDataFiles(URI baseDirectory) { List<DataFile> dataFiles = new ArrayList<>(); try {/* ww w .ja va 2 s.com*/ // e.g. omh File[] namespaceDirectories = new File(baseDirectory).listFiles(); if (namespaceDirectories == null) { return dataFiles; } for (File namespaceDirectory : namespaceDirectories) { // e.g. omh/blood-pressure File[] schemaNameDirectories = namespaceDirectory.listFiles(); if (schemaNameDirectories == null) { continue; } for (File schemaNameDirectory : schemaNameDirectories) { // e.g. omh/blood-pressure/1.0 File[] versionDirectories = schemaNameDirectory.listFiles(); if (versionDirectories == null) { continue; } for (File versionDirectory : versionDirectories) { // e.g. omh/blood-pressure/1.0/shouldPass File[] testDataDirectories = versionDirectory.listFiles(); if (testDataDirectories == null) { continue; } for (File testDataDirectory : testDataDirectories) { // e.g. generic/blood-pressure/1.0/shouldPass/test-data.json File[] testDataFiles = testDataDirectory.listFiles(); if (testDataFiles == null) { continue; } for (File testDataFile : testDataFiles) { JsonNode testData = objectMapper.readTree(testDataFile); dataFiles.add(new DataFile(testDataFile.toURI(), testData)); } } } } } } catch (IOException e) { throw new RuntimeException(format("The data files in directory '%s' can't be loaded.", baseDirectory), e); } return dataFiles; }
From source file:com.opensymphony.xwork2.util.finder.UrlSet.java
public UrlSet relative(File file) throws MalformedURLException { String urlPath = file.toURI().toURL().toExternalForm(); Map<String, URL> urls = new HashMap<String, URL>(); for (Map.Entry<String, URL> entry : this.urls.entrySet()) { String url = entry.getKey(); if (url.startsWith(urlPath) || url.startsWith("jar:" + urlPath)) { urls.put(url, entry.getValue()); }/*from w w w .j a v a 2 s . c o m*/ } return new UrlSet(urls); }
From source file:com.l2jserver.service.game.scripting.impl.ecj.EclipseCompilerScriptClassLoader.java
/** * AddsLibrary jar//from w ww. j a va 2 s. co m * * @param file * jar file to add * @throws IOException * if any I/O error occur */ @Override public void addLibrary(File file) throws IOException { URL fileURL = file.toURI().toURL(); addURL(fileURL); JarFile jarFile = new JarFile(file); Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); String name = entry.getName(); if (name.endsWith(".class")) { name = name.substring(0, name.length() - 6); name = name.replace('/', '.'); libraryClasses.add(name); } } jarFile.close(); }
From source file:maltcms.ui.nb.pipelineRunner.ui.MaltcmsLocalHostExecution.java
protected String buildFileset() { StringBuilder sb = new StringBuilder(); sb.append("\""); int i = 0;/*from www .j av a 2s . c o m*/ for (File s : inputFiles) { sb.append(s.toURI().toString()); if (inputFiles.length > 1 && i < inputFiles.length - 1) { sb.append(","); } i++; } // if (sb.substring(sb.length() - 1).equals(",")) { // sb.replace(sb.length() - 1, sb.length(), ""); // } sb.append("\""); return sb.toString(); }