Example usage for org.apache.commons.io FilenameUtils getBaseName

List of usage examples for org.apache.commons.io FilenameUtils getBaseName

Introduction

In this page you can find the example usage for org.apache.commons.io FilenameUtils getBaseName.

Prototype

public static String getBaseName(String filename) 

Source Link

Document

Gets the base name, minus the full path and extension, from a full filename.

Usage

From source file:com.orange.wro.taglib.config.GroupLoader.java

@Override
public Map<ResourceType, String> getMinimizedResources() {
    Map<ResourceType, String> res = new HashMap<ResourceType, String>();
    String groupName = group.getName();
    Set<String> resourcePaths = wroTagLibConfig.getResourcePaths();

    if (resourcePaths != null) {
        for (String path : resourcePaths) {
            String fileName = FilenameUtils.getName(path);
            String group = wroTagLibConfig.getGroupForFile(fileName);

            if (group != null) {
                if (groupName.equals(FilenameUtils.getBaseName(group))) {
                    String type = FilenameUtils.getExtension(group);
                    res.put(ResourceType.get(type), path);
                }//from w  w w.ja v  a 2  s.co m

            } else {
                if (FilenameUtils.getBaseName(path).startsWith(groupName)) {
                    String type = FilenameUtils.getExtension(path);
                    res.put(ResourceType.get(type), path);
                }
            }
        }
    }

    return res;
}

From source file:edu.scripps.fl.pubchem.app.cids.WriteSDFStage.java

public File newOutputFile(int index) {
    String outputFile = getOutputFile();
    outputFile = new File(outputFile).getAbsoluteFile().toString();
    String path = FilenameUtils.getFullPath(outputFile);
    String name = FilenameUtils.getBaseName(outputFile);
    String ext = FilenameUtils.getExtension(outputFile);
    File file = new File(path, name + "-" + index + "." + ext);
    return file;/*  w  w  w .j  a  v a2  s  . co  m*/
}

From source file:ch.cyberduck.core.transfer.download.RenameFilter.java

@Override
public TransferStatus prepare(final Path file, final Local local, final TransferStatus parent,
        final ProgressListener progress) throws BackgroundException {
    final TransferStatus status = super.prepare(file, local, parent, progress);
    if (status.isExists()) {
        final String filename = file.getName();
        int no = 0;
        do {/* ww  w . j  a v a 2s .co  m*/
            String proposal = String.format("%s-%d", FilenameUtils.getBaseName(filename), ++no);
            if (StringUtils.isNotBlank(FilenameUtils.getExtension(filename))) {
                proposal += String.format(".%s", FilenameUtils.getExtension(filename));
            }
            if (parent.getRename().local != null) {
                status.rename(LocalFactory.get(parent.getRename().local, proposal));
            } else {
                status.rename(LocalFactory.get(local.getParent(), proposal));
            }
        } while (status.getRename().local.exists());
        if (log.isInfoEnabled()) {
            log.info(String.format("Changed download target from %s to %s", local, status.getRename().local));
        }
        if (log.isDebugEnabled()) {
            log.debug(String.format("Clear exist flag for file %s", local));
        }
        status.setExists(false);
    } else {
        if (parent.getRename().local != null) {
            status.rename(LocalFactory.get(parent.getRename().local, file.getName()));
        }
        if (log.isInfoEnabled()) {
            log.info(String.format("Changed download target from %s to %s", local, status.getRename().local));
        }
    }
    return status;
}

From source file:com.centeractive.ws.builder.DefinitionSaveTest.java

public static File getGeneratedFolder(int serviceId) throws WSDLException, IOException {
    URL wsdlUrl = ServiceComplianceTest.getDefinitionUrl(serviceId);
    SoapBuilder builder = new SoapBuilder(wsdlUrl);
    File tempFolder = File.createTempFile("maven-temp", Long.toString(System.nanoTime()));
    if (!tempFolder.delete()) {
        throw new RuntimeException("cannot delete tmp file");
    }/*from   w w w  .ja v a2 s .com*/
    if (!tempFolder.mkdir()) {
        throw new RuntimeException("cannot create tmp folder");
    }
    String fileName = FilenameUtils.getBaseName(wsdlUrl.toString());
    builder.saveWsdl(fileName, tempFolder);
    tempFolder.deleteOnExit();
    return tempFolder;
}

From source file:com.splunk.shuttl.archiver.importexport.csv.CsvBucketCreator.java

private File createBucketDirectory(File csvFile) {
    String csvFileNameWithoutExtension = FilenameUtils.getBaseName(csvFile.getName());
    File bucketFile = new File(csvFile.getParentFile(), csvFileNameWithoutExtension);
    bucketFile.mkdirs();/*from ww  w  .  j  a va  2s .  c  o  m*/
    return bucketFile;
}

From source file:com.googlecode.dex2jar.tools.DeObfInitCmd.java

@Override
protected void doCommandLine() throws Exception {
    if (remainingArgs.length != 1) {
        usage();// w ww.  j  a  va 2 s .  c  o  m
        return;
    }

    File jar = new File(remainingArgs[0]);
    if (!jar.exists()) {
        System.err.println(jar + " is not exists");
        usage();
        return;
    }
    if (output == null) {
        if (jar.isDirectory()) {
            output = new File(jar.getName() + "-deobf-init.txt");
        } else {
            output = new File(FilenameUtils.getBaseName(jar.getName()) + "-deobf-init.txt");
        }
    }

    if (output.exists() && !forceOverwrite) {
        System.err.println(output + " exists, use --force to overwrite");
        usage();
        return;
    }
    System.out.println("generate " + jar + " -> " + output);
    new InitOut().from(jar).maxLength(max).minLength(min).to(output);
}

From source file:com.cognifide.cq.cqsm.core.models.ScriptEditModel.java

@Inject
public ScriptEditModel(SlingHttpServletRequest request, @OSGiService ScriptFinder scriptFinder) {
    Script script = scriptFinder.find(request.getParameter(PATH_PARAM), request.getResourceResolver());
    edit = script != null;/*w w  w. j av a  2 s .  c o  m*/
    if (edit) {
        fileName = FilenameUtils.getBaseName(script.getPath());
        content = script.getData();
    } else {
        fileName = FILE_NAME_DEFAULT;
        content = getContentDefault();
    }
}

From source file:com.sonicle.webtop.vfs.SetupDataFile.java

@Override
public void buildName() {
    //TODO
    name = FilenameUtils.getBaseName(path);
}

From source file:com.themodernway.server.core.file.FileUtils.java

public static final String base(String path) {
    if (null != (path = normalize(path))) {
        return FilenameUtils.getBaseName(path);
    }/*from w ww .java 2s  . c o m*/
    return path;
}

From source file:cop.raml.mocks.ElementMock.java

public ElementMock setName(String name) {
    this.name = name;
    setSimpleName(FilenameUtils.getBaseName(name));
    return this;
}