Replies the dirname of the specified file.

@param filename is the name to parse.
@return the dirname of the specified file.
@see #shortBasename(File)
@see #largeBasename(File)
@see #basename(File)
@see #extension(File)
516053
@Pure
	public static URL dirname(File filename) {
		if (filename == null) {
			return null;
		}
		String parent = fromFileStandardToURLStandard(filename.getParent());
		try {
			if (parent == null || "".equals(parent)) { //$NON-NLS-1$
				if (filename.isAbsolute()) {
					return null;
				}
				return new URL(URISchemeType.FILE.name(), "", CURRENT_DIRECTORY); //$NON-NLS-1$
			}
			// Treat Windows specific.
			if (Pattern.matches("^" + URL_PATH_SEPARATOR + "?[a-zA-Z][:|]$", parent)) { //$NON-NLS-1$ //$NON-NLS-2$
				parent += URL_PATH_SEPARATOR;
			}
			return new URL(URISchemeType.FILE.name(), "", parent); //$NON-NLS-1$
		} catch (MalformedURLException exception) {
			return null;
		}
	}
969946
public static long generationFromSegmentsFileName(String fileName) {
    if (fileName.equals(IndexFileNames.SEGMENTS)) {
      return 0;
    } else if (fileName.startsWith(IndexFileNames.SEGMENTS)) {
      return Long.parseLong(
          fileName.substring(1 + IndexFileNames.SEGMENTS.length()),
          Character.MAX_RADIX);
    } else {
      throw new IllegalArgumentException("fileName \"" + fileName
          + "\" is not a segments file");
    }
  }
643653
public static String getExtension(String fileName) {
        if (fileName.contains(".")) {
            return fileName.substring(fileName.lastIndexOf(".") + 1);
        }
        return "png";
    }
550057
public static String getFileExtension(final String fileName) {
        if (fileName == null) return null;

        final int lastPeriodIndex = fileName.lastIndexOf(".");
        // make sure there is an extension, and that the filename doesn't end with a period
        if (lastPeriodIndex != -1 && lastPeriodIndex < fileName.length() - 1) {
            final String extension = fileName.substring(lastPeriodIndex + 1);
            return extension;
        }

        return null;
    }
373223
String getResourceName(String fileName) {
        // FIXME: there is probably a more robust way to do this

        // Strip off the directory part.
        String dirPath = directory.getPath();
        if (!fileName.startsWith(dirPath)) {
            throw new IllegalStateException("Filename " + fileName + " not inside directory " + dirPath);
        }

        // The problem here is that we need to take the relative part of the
        // filename
        // and break it into components that we can then reconstruct into
        // a resource name (using '/' characters to separate the components).
        // Unfortunately, the File class does not make this task particularly
        // easy.

        String relativeFileName = fileName.substring(dirPath.length());
        File file = new File(relativeFileName);
        LinkedList<String> partList = new LinkedList<>();
        do {
            partList.addFirst(file.getName());
        } while ((file = file.getParentFile()) != null);

        StringBuilder buf = new StringBuilder();
        for (String part : partList) {
            if (buf.length() > 0) {
                buf.append('/');
            }
            buf.append(part);
        }

        return buf.toString();
    }
1349179
public static Observable<String> getFileExtension(final String fileName) {
    return Observable.fromCallable(new Func0<String>() {
      @Override
      public String call() {
        return fileName.substring((fileName.lastIndexOf('.')) + 1);
      }
    });
  }
1358342
def extension_from_filename(filename):
    
    # Parse out any extension specified in filename
    _indx1 = filename.find('[')
    _indx2 = filename.find(']')
    if _indx1 > 0:
        # check for closing square bracket:
        if _indx2 < _indx1:
            raise RuntimeError("Incorrect extension specification in file " \
                                "name \'%s\'." % filename)
        # Read extension name provided
        _fname = filename[:_indx1]
        _extn = filename[_indx1+1:_indx2].strip()
    else:
        _fname = filename
        _extn = None

    return _fname, _extn
330045
public static String[] split(String fileName){
        int dot = fileName.lastIndexOf('.');
        if(dot==-1)
            return new String[]{ fileName, null };
        else
            return new String[] { fileName.substring(0, dot), fileName.substring(dot+1)};
    }
1077612
public static String parseNonceFromDigestFilename(String filename) {
        if (filename == null || !filename.endsWith(".digest")) {
            throw new IllegalArgumentException("Bad digest filename: " + filename);
        }

        return parseNonceFromSnapshotFilename(filename);
    }
852839
public static String getSafeExtension(final String filename) {
        // extension does not include period (.)
        final String extension = FilenameUtils.getExtension(filename);
        return isSafeExtension(extension) ? "." + extension : StringUtils.EMPTY;
    }
1080260
private static int getIndexFromFilename(String fileName) {
        // remove the beginning of the file name
        String resStr = fileName.replace(
                latestMOTDSerializedFileName.substring(0, latestMOTDSerializedFileName.indexOf("{index}")), "");

        // remove the end of the file name
        resStr = resStr.replace(
                latestMOTDSerializedFileName.substring(latestMOTDSerializedFileName.indexOf("{index}") + 7), "");

        return Integer.parseInt(resStr);
    }
311666
public static String getExtension(final String filename) {
        Objects.requireNonNull(filename, "filename cannot be null");
        int lastDotIdx = filename.lastIndexOf(".");
        return lastDotIdx >= 0 ? filename.substring(lastDotIdx) : "";
    }
1337291
public static String getHeaderName(final String basename, final String filename) {
    final String base = basename.replaceAll("\\\\", "/");
    final String file = filename.replaceAll("\\\\", "/");
    if (!file.startsWith(base)) {
      throw new IllegalArgumentException("Error " + file + " does not start with " + base);
    }
    String header = file.substring(base.length() + 1);
    header = header.replaceAll("/", "_");
    header = header.replaceAll("\\.class", ".h");
    return header;
  }
600462
public static String[] splitFileNameIntoPreSuffix(String fileName) {
        String[] preSuffix = {fileName, EMPTY};
        int dotIndex = fileName.lastIndexOf(DOT);
        if (dotIndex > 0) {
            preSuffix[0] = fileName.substring(0, dotIndex);
            preSuffix[1] = fileName.substring(dotIndex);
        }
        return preSuffix;
    }
1072472
public static String getFileExtension(String fileName) {
        int lastDot = fileName.lastIndexOf('.');
        return (lastDot >= 0) ? fileName.substring(lastDot) : null;
    }
23812
public static String getExtension(String fileName) {
        if (fileName == null)
            return null;

        String[] tokens = split(fileName);
        if (tokens.length >= 2)
            return tokens[tokens.length - 1];

        return null;
    }
454843
public String constructShortName() {
        String result = shortName;
        if(dir != null) {
            result = dir + "/" + result;
        }
        if(extension != null) {
            result = result + "." + extension;
        }
        return result;
    }