List of usage examples for java.io File getCanonicalPath
public String getCanonicalPath() throws IOException
From source file:bjerne.gallery.service.impl.GalleryAuthorizationServiceSSImpl.java
private boolean stringStartsWithFile(String string, File f) { try {/*from ww w . j a v a 2s . c o m*/ return string.startsWith(f.getCanonicalPath()); } catch (IOException ioe) { return false; } }
From source file:com.adaptris.core.common.FileDataInputParameterTest.java
@Test public void testExtract() throws Exception { FileDataInputParameter p = new FileDataInputParameter(); File f = TempFileUtils.createTrackedFile(testName.getMethodName(), "", p); p.setUrl("file:///" + f.getCanonicalPath()); FileUtils.write(f, TEXT, false);// w w w. j av a 2 s . c o m AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(); assertNotSame(TEXT, msg.getContent()); assertEquals(TEXT, p.extract(msg)); }
From source file:com.adaptris.core.fs.AggregatingFsConsumeServiceTest.java
public void testService_MultipleMessages() throws Exception { GuidGenerator o = new GuidGenerator(); File tempDir = TempFileUtils.createTrackedDir(o); String url = "file://localhost/" + tempDir.getCanonicalPath().replaceAll("\\\\", "/"); ConsumeDestinationGenerator cdg = createConsumeDestination(url, ".*"); AggregatingFsConsumer afc = createConsumer(cdg, new IgnoreOriginalMimeAggregator()); AggregatingFsConsumeService service = createAggregatingService(afc); try {/*from ww w . jav a2 s . c om*/ writeDataMessage(tempDir, o.safeUUID()); writeDataMessage(tempDir, o.safeUUID()); start(service); AdaptrisMessage msg = new DefaultMessageFactory().newMessage(INITIAL_PAYLOAD); service.doService(msg); MultiPartInput input = MimeHelper.create(msg, false); assertEquals(2, input.size()); } finally { stop(service); } }
From source file:com.adaptris.core.fs.AggregatingFsConsumeServiceTest.java
public void testService() throws Exception { Object o = new Object(); File tempFile = TempFileUtils.createTrackedFile(o); String url = "file://localhost/" + tempFile.getCanonicalPath().replaceAll("\\\\", "/"); ConsumeDestinationGenerator cdg = createConsumeDestination(url, null); AggregatingFsConsumer afc = createConsumer(cdg, new ReplaceWithFirstMessage()); AggregatingFsConsumeService service = createAggregatingService(afc); try {//w w w . ja v a2 s . c om writeDataMessage(tempFile); start(service); AdaptrisMessage msg = new DefaultMessageFactory().newMessage(INITIAL_PAYLOAD); service.doService(msg); assertNotSame(INITIAL_PAYLOAD, msg.getStringPayload()); assertEquals(DATA_PAYLOAD, msg.getStringPayload()); } finally { stop(service); } }
From source file:com.adaptris.core.fs.MarshallingCacheCase.java
public void testPersistenceWithZeroLengthPersistentStore() throws Exception { String oldName = Thread.currentThread().getName(); MarshallingItemCache cache = createCache(); File badStore = File.createTempFile(this.getClass().getSimpleName(), ""); cache.setPersistentStore(badStore.getCanonicalPath()); try {/*from w ww .j av a 2 s. c o m*/ Thread.currentThread().setName("testPersistenceWithZeroLengthPersistentStore"); cache.init(); cache.close(); fail(); } catch (CoreException expected) { log.debug(expected.getMessage(), expected); } finally { Thread.currentThread().setName(oldName); FileUtils.deleteQuietly(badStore); } }
From source file:fr.brouillard.oss.jgitver.JGitverConfigurationComponent.java
@Override public boolean ignore(File pomFile) throws IOException { for (File excludedDir : excludedDirectories) { if (StringUtils.containsIgnoreCase(pomFile.getParentFile().getCanonicalFile().getCanonicalPath(), excludedDir.getCanonicalPath())) { return true; }// ww w .j a va2 s. c o m } return false; }
From source file:com.github.rnewson.couchdb.lucene.Config.java
public final File getDir() throws IOException { final File dir = new File(this.configuration.getString(LUCENE_DIR, DEFAULT_DIR)); if (!dir.exists() && !dir.mkdir()) { throw new IOException("Could not create " + dir.getCanonicalPath()); }//from w w w.j a va 2 s .c o m if (!dir.canRead()) { throw new IOException(dir + " is not readable."); } if (!dir.canWrite()) { throw new IOException(dir + " is not writable."); } LOG.info("Index output goes to: " + dir.getCanonicalPath()); return dir; }
From source file:ca.nines.ise.cmd.Annotations.java
/** * {@inheritDoc}/*from w w w . j a v a 2 s.c om*/ */ @ErrorCode(code = { "dom.errors" }) @Override public void execute(CommandLine cmd) throws Exception { Log log = Log.getInstance(); Locale.setDefault(Locale.ENGLISH); PrintStream logOut = new PrintStream(System.out, true, "UTF-8"); if (cmd.hasOption("l")) { logOut = new PrintStream(new FileOutputStream(cmd.getOptionValue("l")), true, "UTF-8"); } String args[] = getArgList(cmd); File docFile = new File(args[0]); if (!docFile.exists()) { System.err.println("Cannot read document " + docFile.getCanonicalPath()); System.exit(1); } File annFile = new File(args[1]); if (!annFile.exists()) { System.err.println("Cannot read annotations " + annFile.getCanonicalPath()); System.exit(1); } DOM dom = new DOMBuilder(docFile).build(); if (dom.getStatus() != DOM.DOMStatus.ERROR) { Annotation annotation = Annotation.builder().from(annFile).build(); AnnotationValidator av = new AnnotationValidator(); av.validate(dom, annotation); } else { Message m = Message.builder("dom.errors").setSource(dom.getSource()).build(); log.add(m); } if (log.count() > 0) { logOut.print(log); } }
From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.common.ArchiveCompressorTarGzImplFastTest.java
@Test public void testCreateArchive() throws IOException { TarInputStream tin = null;//ww w.ja v a 2 s . c o m try { String testDir = SAMPLE_DIR + "qclive/compression/tar/"; File file1 = new File(testDir + "file1.txt"); File file2 = new File(testDir + "file2.txt"); File file3 = new File(testDir + "file3.txt"); List<File> files = new ArrayList<File>(); files.add(file1); files.add(file2); files.add(file3); // pass in a list of files and verify that a tar.gz file is made ArchiveCompressor compressor = new ArchiveCompressorTarGzImpl(); String archiveName = "test"; File createdFile = compressor.createArchive(files, archiveName, new File(testDir), false); File testFile = new File(testDir + File.separator + archiveName + ".tar"); assertEquals(testFile.getCanonicalPath(), createdFile.getCanonicalPath()); assertTrue(testFile.exists()); // look at tar entries and make sure expected files are there, with just // archive name as the path FileInputStream inputStream = new FileInputStream(testFile); //noinspection IOResourceOpenedButNotSafelyClosed tin = new TarInputStream(inputStream); List<String> tarEntryNames = new ArrayList<String>(); TarEntry tarEntry; while ((tarEntry = tin.getNextEntry()) != null) { tarEntryNames.add(tarEntry.getName()); } tin.close(); assertTrue(tarEntryNames.contains(archiveName + File.separator + "file1.txt")); assertTrue(tarEntryNames.contains(archiveName + File.separator + "file2.txt")); assertTrue(tarEntryNames.contains(archiveName + File.separator + "file2.txt")); testFile.deleteOnExit(); } finally { IOUtils.closeQuietly(tin); } }