Example usage for org.apache.commons.vfs FileObject getName

List of usage examples for org.apache.commons.vfs FileObject getName

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileObject getName.

Prototype

public FileName getName();

Source Link

Document

Returns the name of this file.

Usage

From source file:egovframework.rte.fdl.filehandling.EgovFileUtil.java

/**
 * <p>//www  .  j  ava 2s .c  o m
 *  ?    ??.
 * </p>
 * @param changDirectory
 *        <code>String</code>
 * @throws Exception
 */
public static void cd(final String changDirectory) throws Exception {
    final String path;
    if (!EgovStringUtil.isNull(changDirectory)) {
        path = changDirectory;
    } else {
        path = System.getProperty("user.home");
    }

    // Locate and validate the folder
    FileObject tmp = manager.resolveFile(basefile, path);

    if (tmp.exists()) {
        basefile = tmp;
    } else {
        log.info("Folder does not exist: " + tmp.getName());
    }
    log.info("Current folder is " + basefile.getName());
}

From source file:com.panet.imeta.trans.steps.accessinput.AccessInputMeta.java

public static String getFilename(FileObject fileObject) {
    FileName fileName = fileObject.getName();
    String root = fileName.getRootURI();
    if (!root.startsWith("file:"))
        return fileName.getURI();
    if (root.endsWith(":/"))
        root = root.substring(8, 10);/*from   w ww .  ja v  a 2  s  .  co  m*/
    else
        root = root.substring(7, root.length() - 1);
    String fileString = root + fileName.getPath();
    if (!"/".equals(Const.FILE_SEPARATOR))
        fileString = Const.replace(fileString, "/", Const.FILE_SEPARATOR);
    return fileString;
}

From source file:egovframework.rte.fdl.filehandling.EgovFileUtil.java

/**
 * <p>//from ww w  .ja  v a2 s  . c  om
 *  ? ?? ?  .
 * </p>
 * @param source
 *        <code>String</code>
 * @param target
 *        <code>String</code>
 * @throws Exception
 */
public static void cp(String source, String target) throws Exception {

    try {
        final FileObject src = manager.resolveFile(basefile, source);
        FileObject dest = manager.resolveFile(basefile, target);

        if (dest.exists() && dest.getType() == FileType.FOLDER) {
            dest = dest.resolveFile(src.getName().getBaseName());
        }

        dest.copyFrom(src, Selectors.SELECT_ALL);
    } catch (FileSystemException fse) {
        log.error(fse.toString());
        ;
        throw new FileSystemException(fse);
    }
}

From source file:egovframework.rte.fdl.filehandling.EgovFileUtil.java

/**
 * <p>/* w  w  w .  j  a  va  2s .c  o m*/
 *  ? ?? ?  ??.
 * </p>
 * @param source
 *        <code>String</code>
 * @param target
 *        <code>String</code>
 * @throws Exception
 */
public static void mv(String source, String target) throws Exception {

    try {
        final FileObject src = manager.resolveFile(basefile, source);
        FileObject dest = manager.resolveFile(basefile, target);

        if (dest.exists() && dest.getType() == FileType.FOLDER) {
            dest = dest.resolveFile(src.getName().getBaseName());
        }

        src.moveTo(dest);
    } catch (FileSystemException fse) {
        log.error(fse.toString());
        ;
        throw new FileSystemException(fse);
    }
}

From source file:net.sf.vfsjfilechooser.filechooser.AbstractVFSFileView.java

/**
 * The name of the file. Normally this would be simply
 * <code>f.getName()</code>.
 * @param f//from  w w  w.j  a  v a  2 s. c o  m
 * @return
 */
public String getName(FileObject f) {
    return VFSUtils.getFriendlyName(f.getName().toString());
}

From source file:com.bedatadriven.renjin.appengine.AppEngineLocalFilesSystemProviderTest.java

@Test
public void test() throws FileSystemException {

    File basePath = new File(getClass().getResource("/jarfiletest.jar").getFile()).getParentFile();

    FileSystemManager dfsm = AppEngineContextFactory
            .createFileSystemManager(new AppEngineLocalFilesSystemProvider(basePath));

    FileObject jarFile = dfsm.resolveFile("/jarfiletest.jar");
    assertThat(jarFile.getName().getURI(), equalTo("file:///jarfiletest.jar"));
    assertThat(jarFile.exists(), equalTo(true));

    FileObject jarRoot = dfsm.resolveFile("jar:file:///jarfiletest.jar!/r/library");
    assertThat(jarRoot.exists(), equalTo(true));
    assertThat(jarRoot.getType(), equalTo(FileType.FOLDER));
    assertThat(jarRoot.getChildren().length, equalTo(1));
}

From source file:com.thinkberg.moxo.vfs.s3.S3FileProviderTest.java

public void testGetDirectoryListing() throws FileSystemException {
    FileObject object = VFS.getManager().resolveFile(ROOT + "/Sites/Sites/images");
    FileObject[] files = object.findFiles(new DepthFileSelector(1));
    for (FileObject file : files) {
        System.out.println("Found file: " + file.getName().getPath());
    }/* w  ww  .  j ava  2  s.c  o m*/
    assertEquals(4, files.length);
}

From source file:com.thinkberg.moxo.vfs.s3.S3FileProviderTest.java

public void testDoCreateFileSystem() throws FileSystemException {
    FileObject object = VFS.getManager().resolveFile(ROOT);
    assertEquals(BUCKETID, ((S3FileName) object.getName()).getRootFile());
}

From source file:com.github.stephenc.javaisotools.vfs.provider.iso.IsoFileProvider.java

protected FileSystem doCreateFileSystem(final String scheme, final FileObject file,
        final FileSystemOptions fileSystemOptions) throws FileSystemException {
    final FileName rootName = new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
    return new IsoFileSystem(rootName, file, fileSystemOptions);
}

From source file:com.sonatype.nexus.plugin.groovyconsole.DefaultScriptStorage.java

private boolean isScriptFile(FileObject file) {
    FileName name = file.getName();
    if (name.getBaseName().endsWith(DOT_GROOVY)) {
        return true;
    }/*from   ww w .  j a va2s.co m*/
    return false;
}