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:de.thomasvolk.genexample.bericht.templates.Template.java

public Template(String path) {
    this.name = FilenameUtils.getBaseName(path);
    this.dir = FilenameUtils.getPath(path);
    this.extension = FilenameUtils.getExtension(path);
    this.path = path;
}

From source file:ijfx.ui.utils.NamingUtils.java

public Pair<String, String> separateExtension(String filename) {

    String extension = FilenameUtils.getExtension(filename);
    String basename = FilenameUtils.getBaseName(filename);
    return new Pair<>(basename, extension);
}

From source file:de.mgd.simplesoundboard.service.DefaultSoundResourceService.java

private String enhanceName(final String fileName) {
    return StringUtils.replace(FilenameUtils.getBaseName(fileName), "_", " ");
}

From source file:com.jcalvopinam.core.Zipping.java

/***
 *
 * @param path path of file to core/*ww  w .  j av a 2s.  c  om*/
 * @param fileSize size for each file in MB
 */
public Zipping(String path, int fileSize) throws IOException {
    CustomFile customFile = new CustomFile();
    File inputFile = new File(path);

    customFile.setPath(String.format("%s%s", inputFile.getParent(), File.separator));
    customFile.setFileName(FilenameUtils.getBaseName(inputFile.getName()));
    customFile.setFileNameExtension(inputFile.getName());
    customFile.setFileExtension(FilenameUtils.getExtension(inputFile.getName()));

    int bufferSize = CustomFile.BYTE_SIZE * CustomFile.BYTE_SIZE * fileSize;
    splitAndZipFile(inputFile, bufferSize, customFile);
}

From source file:eu.novait.imageresizer.helpers.ImageFile.java

public String getOutputFilename(String outputdir) {
    String newname = "";
    if (!outputdir.endsWith("/") && !outputdir.endsWith("\"")) {
        outputdir += "/";
    }/* ww w .ja  v  a 2  s.c o m*/
    File f = new File(this.filename);
    String basename = FilenameUtils.getName(filename);
    String ext = FilenameUtils.getExtension(basename);
    String onlyname = FilenameUtils.getBaseName(filename);

    newname = outputdir + basename;
    File outputfile = new File(newname);
    while (outputfile.exists()) {
        int idx = 1;
        newname = outputdir + onlyname + "_" + Integer.toString(idx) + "." + ext;
        outputfile = new File(newname);
        idx++;
    }
    return newname;
}

From source file:MSUmpire.BaseDataStructure.TandemParam.java

public void SetCombineFileName(String filename, String tag) {
    CombinedPepXML = FilenameUtils.separatorsToUnix(FilenameUtils.getFullPath(filename) + "interact-"
            + FilenameUtils.getBaseName(filename) + tag + ".tandem.combine.pep.xml");
    CombinedProt = FilenameUtils.getFullPath(filename) + FilenameUtils.getBaseName(filename) + tag
            + ".tandem.Qcombine.prot.xml";
}

From source file:fr.tpt.atlanalyser.tests.TestNGCExec.java

@Override
public void test() throws IOException {
    File henshinOutputFile = new File(henshinOutputDir,
            FilenameUtils.getBaseName(inputModel.getPath()) + "_henshin.xmi");
    applyHenshinTransformation(inputModel.getPath(), henshinOutputFile.getPath());
}

From source file:com.haulmont.cuba.core.sys.logging.LogArchiver.java

public static void writeArchivedLogToStream(File logFile, OutputStream outputStream) throws IOException {
    if (!logFile.exists()) {
        throw new FileNotFoundException();
    }//from   w w w  . j  a  v a  2  s .  c o  m

    File tempFile = File.createTempFile(FilenameUtils.getBaseName(logFile.getName()) + "_log_", ".zip");

    ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(tempFile);
    zipOutputStream.setMethod(ZipArchiveOutputStream.DEFLATED);
    zipOutputStream.setEncoding(ZIP_ENCODING);

    ArchiveEntry archiveEntry = newArchive(logFile);
    zipOutputStream.putArchiveEntry(archiveEntry);

    FileInputStream logFileInput = new FileInputStream(logFile);
    IOUtils.copyLarge(logFileInput, zipOutputStream);

    logFileInput.close();

    zipOutputStream.closeArchiveEntry();
    zipOutputStream.close();

    FileInputStream tempFileInput = new FileInputStream(tempFile);
    IOUtils.copyLarge(tempFileInput, outputStream);

    tempFileInput.close();

    FileUtils.deleteQuietly(tempFile);
}

From source file:com.googlecode.dex2jar.test.ResTest.java

@Test
public void test() throws Exception {
    File dir = new File("target/test-classes/res");
    Map<String, List<File>> m = new HashMap<String, List<File>>();
    for (File f : FileUtils.listFiles(dir, new String[] { "class" }, false)) {
        String name = FilenameUtils.getBaseName(f.getName());

        int i = name.indexOf('$');
        String z = i > 0 ? name.substring(0, i) : name;
        List<File> files = m.get(z);
        if (files == null) {
            files = new ArrayList<File>();
            m.put(z, files);/*from   ww w .  ja va  2  s .  c o  m*/
        }
        files.add(f);
    }

    List<Exception> exes = new ArrayList<Exception>();
    System.out.flush();
    int count = 0;
    for (Entry<String, List<File>> e : m.entrySet()) {
        String name = e.getKey();
        count++;
        try {
            File dex = TestUtils.dex(e.getValue(), new File(dir, name + ".dex"));
            File distFile = new File(dex.getParentFile(),
                    FilenameUtils.getBaseName(dex.getName()) + "_dex2jar.jar");
            Dex2jar.from(dex).reUseReg().skipDebug().optimizeSynchronized().topoLogicalSort().to(distFile);
            TestUtils.checkZipFile(distFile);
            System.out.write('.');
        } catch (Exception ex) {
            exes.add(ex);
            System.out.write('X');
        }
        if (count % 5 == 0) {
            System.out.write('\n');
        }
        System.out.flush();
    }
    System.out.flush();
    System.out.println();
    if (exes.size() > 0) {
        for (Exception ex : exes) {
            ex.printStackTrace(System.err);
        }
        throw new RuntimeException("there are " + exes.size() + " errors while translate");
    }
}

From source file:eu.operando.proxy.database.model.FilterFile.java

public String getTitle() {
    return FilenameUtils.getBaseName(source) + " (" + filterCount + " entries)";
}