Android Utililty Methods File Name Get

List of utility methods to do File Name Get

Description

The list of methods to do File Name Get are organized into topic(s).

Method

StringgetFileName()
get File Name
SimpleDateFormat format = new SimpleDateFormat(
        "yyyy-MM-dd_HH-mm-ss_SS");
String fileName = format.format(new Timestamp(System
        .currentTimeMillis()));
return fileName;
StringgetFileName(String path)
get File Name
return path.substring(path.lastIndexOf("/") + 1);
StringgetFileNameFromURL(String url)
Dado o url de um ficheiro deviolve o seu nome.
if (url == null) {
    return null;
} else if (url.equals("")) {
    return url;
} else {
    return (url.substring(url.lastIndexOf("/") + 1));
StringgetFileNameFromURL(URL url)
get File Name From URL
String fileName = url.getFile();
return fileName.substring(fileName.lastIndexOf('/') + 1);
StringgetFileNameOnly(String filename)
get File Name Only
String extension = filename.substring(0, filename.lastIndexOf("."));
return extension;
StringgetFilenameFromPath(String path)
get Filename From Path
return new File(path).getName();