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

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

Introduction

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

Prototype

public static String getName(String filename) 

Source Link

Document

Gets the name minus the path from a full filename.

Usage

From source file:com.splunk.shuttl.archiver.util.UtilsURI.java

/**
 * Trim eventual ending {@link File#separator} and return base name.<br/>
 * Ex:<br/>/*from   www  . j ava2s  .com*/
 * 
 * <pre>
 * "file:/a/b/c" -> "c"
 * "file:/a/b/c/" -> "c"
 * "file:/a/b/c.txt" -> "c.txt"
 * </pre>
 */
public static String getFileNameWithTrimmedEndingFileSeparator(URI uri) {
    String path = getPathByTrimmingEndingFileSeparator(uri);
    return FilenameUtils.getName(path);
}

From source file:AIR.Common.Utilities.Path.java

public static String getFileName(String path) {
    return FilenameUtils.getName(path);
}

From source file:mesclasses.util.EleveFileUtil.java

public static String copyFileForEleve(Eleve eleve, File file, String type) throws IOException {
    File eleveDir = getEleveDirWithType(eleve, type);
    eleveDir.mkdirs();//from  ww w  . ja  v  a 2s  . c om
    String fileName = FilenameUtils.getName(file.getPath());
    File newFile = new File(eleveDir.getPath() + File.separator + fileName);
    if (newFile.exists()) {
        throw new IOException(
                "Le fichier " + fileName + " de type " + type + " existe dj pour " + eleve.getFirstName());
    }
    FileUtils.copyFile(file, newFile);
    return newFile.getPath();
}

From source file:edu.umn.msi.tropix.proteomics.conversion.DtaNameUtils.java

public static boolean isDtaName(final String filename) {
    return DTA_PATTERN.matcher(FilenameUtils.getName(filename)).matches();
}

From source file:com.docd.purefm.utils.BookmarksHelper.java

@NonNull
public static BookmarkItem createUserBookmarkItem(@NonNull final Activity activity,
        @NonNull final String path) {
    final BookmarkItem item = new BookmarkItem();
    item.mDisplayName = FilenameUtils.getName(path);
    if (item.mDisplayName.equals(Environment.sRootDirectory.getAbsolutePath())) {
        item.mDisplayName = activity.getText(R.string.root);
    }/*www .  j  ava  2 s  . c  o  m*/
    item.mDisplayPath = path;
    item.mIcon = ThemeUtils.getDrawableNonNull(activity.getTheme(), R.attr.ic_bookmark);
    return item;
}

From source file:cat.calidos.morfeu.model.transform.injection.StringFormatModule.java

@Produces
@Named("EffectiveContent")
public static String produceEffectiveContent(@Named("DestinationContentURI") URI uri,
        @Named("TransformedContent") Producer<String> transformedContentProducer,
        @Named("Content") Producer<String> contentProducer) throws TransformException {

    String name = FilenameUtils.getName(uri.getPath());

    try {//from   w w  w  .  j ava2 s. c o  m
        if (name.endsWith("yaml")) {

            return transformedContentProducer.get().get();

        } else {

            return contentProducer.get().get(); // no transformation required

        }
    } catch (InterruptedException | ExecutionException e) {
        log.error("Could not get effective content for '{}' ({})", uri, e);
        throw new TransformException("Problem when getting effective content to save '" + uri + "'", e);
    }

}

From source file:edu.umn.msi.tropix.proteomics.conversion.DtaNameUtils.java

public static DtaNameSummary getDtaNameSummary(final String filename) {
    final Matcher matcher = DTA_PATTERN.matcher(FilenameUtils.getName(filename));
    matcher.matches();/* w  w w.j  a  va  2s  . c  o m*/
    final String basename = matcher.group(1);
    final int start = Integer.parseInt(matcher.group(2));
    final int end = Integer.parseInt(matcher.group(3));
    final short charge = Short.parseShort(matcher.group(4));
    return new DtaNameSummary(basename, start, end, charge);
}

From source file:com.frostwire.android.gui.transfers.UIHttpDownload.java

private static Info convert(Slide slide) {
    return new Info(slide.httpDownloadURL == null ? slide.torrent : slide.httpDownloadURL,
            FilenameUtils.getName(slide.httpDownloadURL == null ? slide.torrent : slide.httpDownloadURL),
            slide.title, slide.size);/*from   w ww . ja v  a2  s . c  om*/
}

From source file:com.fileOperations.WordToPDF.java

/**
 * Creates PDF from DOCX, does this by opening file and "SaveAs" within
 * Microsoft Office itself and closing out.
 *
 * @param filePath String/*from  w w  w  .  j av  a 2s.  c  o m*/
 * @param fileName String
 * @return String - new File Name
 */
public static String createPDF(String filePath, String fileName) {
    ActiveXComponent eolWord = null;
    String docxFile = filePath + fileName;
    String pdfFile = filePath + FilenameUtils.removeExtension(fileName) + ".pdf";

    File attachmentLocation = new File(filePath);
    if (!attachmentLocation.exists()) {
        attachmentLocation.mkdirs();
    }

    eolWord = JacobCOMBridge.setWordActive(true, false, eolWord);
    if (eolWord != null) {
        try {
            //Open MS Word & Save AS
            Dispatch document = eolWord.getProperty("Documents").toDispatch();
            Dispatch.call(document, "Open", docxFile).toDispatch();
            Dispatch WordBasic = Dispatch.call(eolWord, "WordBasic").getDispatch();
            Dispatch.call(WordBasic, "FileSaveAs", pdfFile, new Variant(17));
            Dispatch.call(document, "Close", new Variant(false));
            Thread.sleep(250);

            //Close out MS Word
            JacobCOMBridge.setWordActive(false, false, eolWord);
            Dispatch.call(eolWord, "Quit");
            eolWord.safeRelease();
            File oldDoc = new File(docxFile);
            oldDoc.delete();
            return FilenameUtils.getName(pdfFile);
        } catch (InterruptedException ex) {
            ExceptionHandler.Handle(ex);
            return "";
        }
    }
    return "";
}

From source file:com.bt.download.android.gui.transfers.SlideDownloadLink.java

public SlideDownloadLink(Slide slide) {
    super(slide.httpUrl, FilenameUtils.getName(slide.httpUrl), slide.title, slide.size, slide.uncompress);
    this.slide = slide;
}