List of usage examples for org.apache.commons.vfs2 FileObject getFileSystem
FileSystem getFileSystem();
From source file:org.ysb33r.groovy.vfsplugin.cpio.CpioFileSystem.java
protected CpioFileSystem(final AbstractFileName rootName, final FileObject parentLayer, final FileSystemOptions fileSystemOptions) throws FileSystemException { super(rootName, parentLayer, fileSystemOptions); // Make a local copy of the file file = parentLayer.getFileSystem().replicateFile(parentLayer, Selectors.SELECT_SELF); // Open the Cpio file if (!file.exists()) { // Don't need to do anything cpioFile = null;/* ww w .ja v a 2 s . c om*/ return; } // cpioFile = createCpioFile(this.file); }
From source file:sf.net.experimaestro.connectors.SingleHostConnector.java
/** * Resolve a FileObject to a local path/* w w w. ja va2 s. c om*/ * <p/> * Throws an exception when the file name cannot be resolved, i.e. when * the file object is not */ public String resolve(FileObject file) throws FileSystemException { if (!contains(file.getFileSystem())) { throw new FileSystemException(format("Cannot resolve file %s within filesystem %s", file, this)); } return file.getName().getPath(); }
From source file:tain.kr.test.vfs.v01.ShowProperties.java
private static void test01(String[] args) throws Exception { if (flag)/*from w ww . j a v a 2 s .c o m*/ new ShowProperties(); if (flag) { if (args.length == 0) { System.err.println("Please pass the name of a file as parameter."); System.err.println("e.g. java org.apache.commons.vfs2.example.ShowProperties LICENSE.txt"); return; } for (final String arg : args) { try { final FileSystemManager mgr = VFS.getManager(); System.out.println(); System.out.println("Parsing : " + arg); final FileObject file = mgr.resolveFile(arg); System.out.println("URL : " + file.getURL()); System.out.println("getName() : " + file.getName()); System.out.println("BaseName : " + file.getName().getBaseName()); System.out.println("Extension : " + file.getName().getExtension()); System.out.println("Path : " + file.getName().getPath()); System.out.println("Scheme : " + file.getName().getScheme()); System.out.println("URI : " + file.getName().getURI()); System.out.println("Root URI : " + file.getName().getRootURI()); System.out.println("Parent : " + file.getName().getParent()); System.out.println("Type : " + file.getType()); System.out.println("Exists : " + file.exists()); System.out.println("Readable : " + file.isReadable()); System.out.println("Writeable : " + file.isWriteable()); System.out.println("Root path : " + file.getFileSystem().getRoot().getName().getPath()); if (file.exists()) { if (file.getType().equals(FileType.FILE)) { System.out.println("Size: " + file.getContent().getSize() + " bytes"); } else if (file.getType().equals(FileType.FOLDER) && file.isReadable()) { final FileObject[] children = file.getChildren(); System.out.println("Directory with " + children.length + " files"); for (int iterChildren = 0; iterChildren < children.length; iterChildren++) { System.out.println("#" + iterChildren + ": " + children[iterChildren].getName()); if (iterChildren > SHOW_MAX) { break; } } } System.out.println("Last modified: " + DateFormat.getInstance() .format(new Date(file.getContent().getLastModifiedTime()))); } else { System.out.println("The file does not exist"); } file.close(); } catch (final FileSystemException ex) { ex.printStackTrace(); } } } }