List of usage examples for java.io File getCanonicalFile
public File getCanonicalFile() throws IOException
From source file:it.cnr.icar.eric.client.admin.function.Lcd.java
public void execute(AdminFunctionContext context, String args) throws Exception { File newLocalDir; if (args == null) { newLocalDir = FileSystemView.getFileSystemView().getDefaultDirectory(); } else {/* w ww . j a va 2s .c om*/ String useArgs = AdminShellUtility.getInstance().normalizeArgs(args); newLocalDir = new File(useArgs); newLocalDir = newLocalDir.getCanonicalFile(); } if (!newLocalDir.isDirectory()) { throw new AdminException(format(rb, "notDirectory", new Object[] { newLocalDir })); } context.setLocalDir(newLocalDir); if (context.getDebug()) { context.printMessage(":" + newLocalDir + ":"); } }
From source file:org.spoutcraft.launcher.launch.MinecraftClassLoader.java
private Enumeration<URL> getEnumeration(String resource, String key) throws MalformedURLException { ArrayList<URL> list = new ArrayList<URL>(1); File file = new File(resource); if (file.exists()) { try {/*from ww w.j a v a 2 s . c o m*/ list.add(file.getCanonicalFile().toURI().toURL()); } catch (IOException e) { list.add(file.toURI().toURL()); } resources.put(key, list); return new IteratorEnumerator(list.iterator()); } return null; }
From source file:org.xwiki.environment.internal.ServletEnvironmentTest.java
@Test public void getTemporaryDirectoryWhenNotSet() throws Exception { ServletContext servletContext = mock(ServletContext.class); when(servletContext.getAttribute("javax.servlet.context.tempdir")).thenReturn(this.servletTmpDir); this.environment.setServletContext(servletContext); File tmpDir = this.environment.getTemporaryDirectory(); // Make sure it is the "xwiki-temp" dir which is under the main temp dir. assertEquals(this.servletTmpDir.listFiles()[0].getCanonicalFile(), tmpDir.getCanonicalFile()); }
From source file:name.martingeisse.webide.features.java.compiler.classpath.ClassFolderLibraryFileManager.java
/** * Constructor./*from www . j a va 2s . com*/ * @param folder the folder * @param next the next file manager to search */ public ClassFolderLibraryFileManager(final File folder, final JavaFileManager next) { super(folder.getPath(), next); this.folder = ParameterUtil.ensureNotNull(folder, "folder"); try { this.canonicalFolder = folder.getCanonicalFile(); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:android.databinding.compilationTest.SimpleCompilationTest.java
@Test public void testIncludeInMerge() throws Throwable { prepareProject();/*from ww w.ja v a2 s . c o m*/ copyResourceTo("/layout/merge_include.xml", "/app/src/main/res/layout/merge_include.xml"); CompilationResult result = runGradle("assembleDebug"); assertNotEquals(0, result.resultCode); List<ScopedException> errors = ScopedException.extractErrors(result.error); assertEquals(result.error, 1, errors.size()); final ScopedException ex = errors.get(0); final ScopedErrorReport report = ex.getScopedErrorReport(); final File errorFile = new File(report.getFilePath()); assertTrue(errorFile.exists()); assertEquals(new File(testFolder, "/app/src/main/res/layout/merge_include.xml").getCanonicalFile(), errorFile.getCanonicalFile()); assertEquals("Merge shouldn't support includes as root. Error message was '" + result.error, ErrorMessages.INCLUDE_INSIDE_MERGE, ex.getBareMessage()); }
From source file:com.seer.datacruncher.eventtrigger.DynamicClassLoader.java
public boolean addSourceDir(File srcDir) { try {/*from w ww.jav a 2s .c o m*/ srcDir = srcDir.getCanonicalFile(); } catch (IOException e) { // ignore } synchronized (sourceDirectories) { if (CollectionUtils.isNotEmpty(sourceDirectories)) { for (Object obj : sourceDirectories) { SourceDirectory sDirectory = (SourceDirectory) obj; if (sDirectory.srcDir.equals(srcDir)) { return false; } } } SourceDirectory sDirectory = new SourceDirectory(srcDir); sourceDirectories.add(sDirectory); } return true; }
From source file:org.broadinstitute.gatk.utils.io.IOUtilsUnitTest.java
@Test public void testRelativeSubDir() throws IOException { File subDir = IOUtils.absolute(new File("."), new File("path/to/file")); Assert.assertEquals(subDir.getCanonicalFile(), new File("path/to/file").getCanonicalFile()); subDir = IOUtils.absolute(new File("/different/path"), new File("path/to/file")); Assert.assertEquals(subDir, new File("/different/path/path/to/file")); }
From source file:io.wcm.maven.plugins.i18n.TransformMojo.java
/** * Get directory containing source i18n files. * @return directory containing source i18n files. * @throws IOException/*from www. j av a 2 s . c o m*/ */ private File getSourceDirectory() throws IOException { File file = new File(source); if (!file.isDirectory()) { getLog().debug("Could not find directory at '" + source + "'"); } return file.getCanonicalFile(); }
From source file:org.apache.openejb.maven.plugin.customizer.monkey.jar.JarPatcher.java
private void jar(final int method, final File exploded, final File target) { JarArchiveOutputStream stream = null; try {/*from w ww.ja v a 2 s .co m*/ stream = new JarArchiveOutputStream(new FileOutputStream(target)); final String prefix = exploded.getCanonicalFile().getAbsolutePath() + File.separator; for (final String f : exploded.list()) { jar(method, stream, new File(exploded, f).getCanonicalFile(), prefix); } } catch (final IOException e) { throw new IllegalArgumentException(e); } finally { IO.close(stream); } }
From source file:org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexRootDirectory.java
@CheckForNull private LocalIndexDir findMatchingIndexDir(File dir) throws IOException { //Resolve to canonical file so that equals can work reliable dir = dir.getCanonicalFile(); Map<String, List<LocalIndexDir>> mapping = getIndexesPerPath(); for (Map.Entry<String, List<LocalIndexDir>> e : mapping.entrySet()) { for (LocalIndexDir idxDir : e.getValue()) { if (idxDir.dir.equals(dir)) { return idxDir; }/*from w w w .j a v a 2 s. com*/ } } return null; }