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

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

Introduction

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

Prototype

FileName getName();

Source Link

Document

Returns the name of this file.

Usage

From source file:com.stratuscom.harvester.PropertiesFileReader.java

@Init
public void initialize() {
    try {// w w w  .ja v a  2s  . c  o  m
        FileObject[] childFiles = fileUtility.getProfileDirectory().getChildren();
        for (FileObject fo : childFiles) {
            if (fo.getName().getBaseName().endsWith(Strings.DOT_PROPERTIES) && fo.getType() == FileType.FILE) {
                readPropertiesFile(fo);
            }
        }
    } catch (Exception ex) {
        throw new LocalizedRuntimeException(ex, MessageNames.BUNDLE_NAME, MessageNames.FAILED_READ_PROPERTIES);
    }
}

From source file:com.googlecode.vfsjfilechooser2.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 2s .  c  o  m*/
 * @return
 */
public String getName(FileObject f) {
    return VFSUtils.getFriendlyName(f.getName().toString());
}

From source file:com.sonicle.webtop.vfs.sfs.StoreFileSystem.java

public String getRelativePath(FileObject fo) {
    return relativizePath(fo.getName().getPath());
}

From source file:edu.scripps.fl.pubchem.app.RelationDownloader.java

public void call() throws Exception {
    Pattern pattern = Pattern.compile("^AID(\\d+)\\s+AID(\\d+)$");

    FileObject folder = VFS.getManager().resolveFile(assayNeighborURL);
    for (FileObject rFile : folder.getChildren()) {
        String name = rFile.getName().getBaseName();
        log.info("Processing file: " + name);
        BufferedReader reader = new BufferedReader(new InputStreamReader(rFile.getContent().getInputStream()));
        String line = null;/*from   w  w  w  .  j a  va  2s  . c o m*/
        long lastFrom = 0;
        List<Relation> relations = new ArrayList(100);
        while (null != (line = reader.readLine())) {
            Matcher matcher = pattern.matcher(line);
            if (!matcher.matches())
                throw new java.lang.UnsupportedOperationException("Cannot determine AIDs from line: " + line);
            long from = Long.parseLong(matcher.group(1));
            long to = Long.parseLong(matcher.group(2));
            if (lastFrom == 0) // very first time only.
                lastFrom = from;
            if (from != lastFrom) { // when we change to the next aid in the file
                update(from, name, relations);
                PubChemDB.getSession().clear();
                lastFrom = from;
            }
            Relation relation = new Relation();
            relation.setFromDb("pcassay");
            relation.setToDb("pcassay");
            relation.setFromId(from);
            relation.setToId(to);
            relation.setRelationName(name);
            relations.add(relation);
        }
        update(lastFrom, name, relations);
    }
}

From source file:com.streamsets.pipeline.stage.destination.remote.FTPRemoteUploadTargetDelegate.java

@Override
public RemoteFile getFile(String remotePath) throws IOException {
    FileObject fileObject = resolveChild(remotePath);
    return new FTPRemoteFile(relativizeToRoot(fileObject.getName().getPath()), 0, fileObject);
}

From source file:com.stratuscom.harvester.PropertiesFileReader.java

private void readPropertiesFile(FileObject fo) throws FileSystemException, IOException {
    String name = fo.getName().getBaseName();
    Properties props = getProperties(fo);
    context.put(name, props);/*from   ww  w.  j a  v a  2s .  co  m*/
    log.log(Level.FINE, MessageNames.READ_PROPERTIES_FILE, name);
    if (log.isLoggable(Level.FINER)) {
        log.log(Level.FINER, MessageNames.READ_PROPERTIES, Utils.format(props));
    }
}

From source file:fr.cls.atoll.motu.processor.wps.TestServiceMetadata.java

public static String[] getServiceMetadataSchemaAsString(String schemaPath) throws MotuException {

    List<String> stringList = new ArrayList<String>();
    String localIso19139SchemaPath = "file:///c:/tempVFS/testISO";
    String localIso19139RootSchemaRelPath = "/srv/srv.xsd";
    String localIso19139RootSchemaPath = String.format("%s%s", localIso19139SchemaPath,
            localIso19139RootSchemaRelPath);

    FileObject dest = Organizer.resolveFile(localIso19139RootSchemaPath);
    boolean hasIso19139asLocalSchema = false;
    try {//from  www  . ja  va  2s . c  om
        if (dest != null) {
            hasIso19139asLocalSchema = dest.exists();
        }
    } catch (FileSystemException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    if (hasIso19139asLocalSchema) {
        try {
            dest.close();
        } catch (FileSystemException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    } else {

        // URL url = Organizer.findResource("schema/iso/srv/srv.xsd");
        // URL url =
        // Organizer.findResource("J:/dev/iso/19139/20070417/schema/src/main/resources/iso/19139/20070417/srv/srv.xsd");
        // URL url = Organizer.findResource("iso/19139/20070417/srv/srv.xsd");
        URL url = Organizer.findResource(schemaPath);
        System.out.println(url);

        // String[] arr = url.toString().split("!");

        // FileObject jarFile = Organizer.resolveFile(arr[0]);
        FileObject jarFile = Organizer.resolveFile(url.toString());

        // List the children of the Jar file
        FileObject[] children = null;
        try {
            children = jarFile.getChildren();
        } catch (FileSystemException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println("Children of " + jarFile.getName().getURI());
        for (int i = 0; i < children.length; i++) {
            System.out.println(children[i].getName().getBaseName());
        }

        dest = Organizer.resolveFile(localIso19139SchemaPath);
        Organizer.deleteDirectory(dest);

        Organizer.copyFile(jarFile, dest);
    }

    // stringList.add(url.toString());
    // stringList.add("J:/dev/iso/19139/20070417/schema/src/main/resources/iso/19139/20070417/srv/srv.xsd");
    stringList.add(localIso19139RootSchemaPath);
    // stringList.add("C:/Documents and Settings/dearith/Mes documents/Atoll/SchemaIso/srv/serviceMetadata.xsd");
    String[] inS = new String[stringList.size()];
    inS = stringList.toArray(inS);
    return inS;
}

From source file:com.googlecode.vfsjfilechooser2.utils.DefaultFileObjectConverter.java

/**
 * Converts the {@link FileObject} object into a Java file object.
 * //  w w w  .  j ava  2  s  .com
 * @param file   the object to convert
 * @return      the generated object, or null if failed to convert
 */
@Override
public File convertFileObject(FileObject file) {
    if (file == null)
        return null;
    try {
        return new File(new URI(file.getName().getURI().replace(" ", "%20")));
    } catch (Exception e) {
        System.err.println("Failed to convert '" + file + "' into file!");
        e.printStackTrace();
        return null;
    }
}

From source file:com.stratuscom.harvester.codebase.ClassServerCodebaseContext.java

@Override
public void addFile(FileObject file) {

    /* Add the mapping into our list of objects. */
    String path = file.getName().getBaseName();
    fileEntries.put(path, file);//from w  w w.ja  v a 2 s.c  o  m
    /* Force update of the codebase. */
    codebaseAnnotation = null;
}

From source file:com.sonicle.webtop.vfs.bol.js.JsPubGridFile.java

public JsPubGridFile(String fileId, FileObject fo) {
    this.fileId = fileId;
    this.type = getFileType(fo);
    this.name = fo.getName().getBaseName();
    this.ext = fo.getName().getExtension();
    this.size = getFileSize(fo);
    this.lastModified = getFileLastModified(fo);
}