Java Path File Name nio getFilename (final String filepath)

Here you can find the source of getFilename (final String filepath)

Description

get Filename

License

Apache License

Return

name of file *or* directory.

Declaration

public static String getFilename (final String filepath)
    

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file

import java.nio.file.Path;
import java.nio.file.Paths;

import java.util.Arrays;

public class Main {
    /**/*from  w w w  . j ava 2s  .c o m*/
     * @return name of file *or* directory.
     */
    public static String getFilename(final String filepath) {
        final Path p = Paths.get(filepath);
        final Path filename = p.getFileName();

        return filename == null ? null : filename.toString();
    }

    /** Varargs wrapper */
    public static String toString(final Object... objects) {
        return Arrays.toString(objects);
    }
}

Related

  1. getDeckNameFromFile(final Path deckFile)
  2. getDefaultPathName(final String address, final long lspId)
  3. getDirectoryNames(Path baseDirectory)
  4. getFileContent(String fileNameOrPath)
  5. getFileInFolder(Path p, String filename)
  6. getFilename(final Path path)
  7. getFilename(final Path path)
  8. getFileName(Path path)
  9. getFileName(Path path)