List of usage examples for org.apache.commons.vfs FileObject getURL
public URL getURL() throws FileSystemException;
From source file:unitTests.dataspaces.VFSMountManagerHelperTest.java
/** * Tests closing all FileSystems/*from w w w . j a va2 s .co m*/ * @throws Exception */ @Ignore("vfs close file system doesn't seem to work properly") @Test public void testCloseFileSystems() throws Exception { logger.info("*************** testCloseFileSystems"); String[] validUrls = server.getVFSRootURLs(); ArrayList<FileObject> fos = new ArrayList<FileObject>(); for (String validUrl : validUrls) { FileObject mounted = VFSMountManagerHelper.mount(validUrl); Assert.assertTrue(mounted.exists()); fos.add(mounted); } VFSMountManagerHelper.closeFileSystems(Arrays.asList(validUrls)); boolean onlyExceptions = true; for (FileObject closedFo : fos) { try { FileObject toto = closedFo.resolveFile("toto"); toto.createFile(); onlyExceptions = false; logger.error(toto.getURL() + " exists : " + toto.exists()); } catch (FileSystemException e) { // this should occur } } Assert.assertTrue("Only Exceptions received", onlyExceptions); }
From source file:us.paulevans.basicxslt.Utils.java
/** * Returns the contents of the input XSL file as a Source object. Uses * Apache Jakarta commons-VFS to resolve the location. * @param aURI/*from ww w . j ava 2 s . c o m*/ * @return */ public static final Source getXSLSource(FileSystemManager aFSMgr, String aURI) { FileObject file; FileContent content; try { file = aFSMgr.resolveFile(aURI); content = file.getContent(); return new StreamSource(content.getInputStream(), file.getURL().toURI().toString()); } catch (Throwable any) { throw new RuntimeException(any); } }