Android File Name Get getFileName(String filePath)

Here you can find the source of getFileName(String filePath)

Description

get File Name

License

Apache License

Declaration

public static String getFileName(String filePath) 

Method Source Code

//License from project: Apache License 

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Main{
    public static String getFileName(String filePath) {
        if (StringUtil.isEmpty(filePath)) {
            return null;
        }//from www .j av  a 2 s .c  o  m

        int pos = filePath.lastIndexOf(File.separator);
        if (pos == -1) {
            return null;
        }
        return filePath.substring(pos + 1);
    }
}

Related

  1. getFileName(String fileName)
  2. getFileName(String path)
  3. getRandomFileName(String prefix, String suffix)
  4. parseFileName(String path)
  5. getSuffix(File file)