Gets prefix of file name.

@param fileName the file name
@return the prefix of file name
164247
public static String getPrefixOfFileName(String fileName) {
        int dotIndex = fileName.lastIndexOf(DOT);
        return dotIndex > 0 ? fileName.substring(0, dotIndex) : fileName;
    }
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;
  }
150186
public static String mainName(String fileName) {
		if (null == fileName) {
			return fileName;
		}
		int len = fileName.length();
		if (0 == len) {
			return fileName;
		}
		if (CharUtil.isFileSeparator(fileName.charAt(len - 1))) {
			len--;
		}

		int begin = 0;
		int end = len;
		char c;
		for (int i = len - 1; i > -1; i--) {
			c = fileName.charAt(i);
			if (len == end && CharUtil.DOT == c) {
				// 查找最后一个文件名和扩展名的分隔符：.
				end = i;
			}
			if (0 == begin || begin > end) {
				if (CharUtil.isFileSeparator(c)) {
					// 查找最后一个路径分隔符（/或者\），如果这个分隔符在.之后，则继续查找，否则结束
					begin = i + 1;
					break;
				}
			}
		}

		return fileName.substring(begin, end);
	}
541495
private static String nameOnly(final String filename) {
        final int p = filename.lastIndexOf('.');
        if (p == -1) {
            return filename;
        }
        return filename.substring(0, p);
    }
134637
public static String fileAsString(String filename) {
    File classpathFile = getClasspathFile(filename);
    return fileAsString(classpathFile);
  }
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;
    }
645389
private static final String getExtension(String fileName) {
		return fileName.indexOf('.') == -1 ? null : fileName.substring(fileName.lastIndexOf('.') + 1);
	}
239143
public static String getName(String fileName){
        int dot = fileName.lastIndexOf('.');
        return dot==-1 ? fileName : fileName.substring(0, dot);
    }
49196
public static String getBaseName(String fileName) {
        if (fileName == null)
            return null;

        String[] tokens = split(fileName);
        return tokens[0];
    }
297724
@Pure
	public static File removeExtension(File filename) {
		if (filename == null) {
			return null;
		}
		final File dir = filename.getParentFile();
		final String name = filename.getName();
		final int idx = name.lastIndexOf(getFileExtensionCharacter());
		if (idx < 0) {
			return filename;
		}
		return new File(dir, name.substring(0, idx));
	}
1159485
public static String getExtension(String fileName){
        int dot = fileName.lastIndexOf('.');
        return dot==-1 ? null : fileName.substring(dot+1);
    }
1141298
public static String getFileExtension(String _fileName) {
        if (_fileName == null) {
            return null;
        }
        int lastDot = _fileName.lastIndexOf('.');
        if (lastDot == -1) {
            return "";
        }
        return _fileName.substring(lastDot + 1);
    }
1016398
protected static String getExtension(String scriptName)
    {
        if (scriptName == null)
        {
            return null;
        }

        int filePosition = scriptName.lastIndexOf("/");
        String fileName;

        if (scriptName.lastIndexOf("\\") > filePosition)
        {
            filePosition = scriptName.lastIndexOf("\\");
        }

        if (filePosition >= 0)
        {
            fileName = scriptName.substring(filePosition + 1);
        }
        else
        {
            fileName = scriptName;
        }

        final int extensionPosition = fileName.lastIndexOf(".");
        if (extensionPosition >= 0)
        {
            return fileName.substring(extensionPosition + 1);
        }

        return null;
    }
717208
public static String getSafeFileName( String fileName ) {
        // not allowed chars in win and linux
        char[] notAllowed = new char[]{'/', '>', '<', ':', '"', '/', '\\', '|', '?', '*'};
        char escape = '_';
        int len = fileName.length();
        StringBuilder sb = new StringBuilder(len);
        for( int i = 0; i < len; i++ ) {
            char ch = fileName.charAt(i);

            boolean trapped = false;
            for( char forbidden : notAllowed ) {
                if (ch == forbidden) {
                    sb.append(escape);
                    trapped = true;
                    break;
                }
            }

            if (!trapped) {
                sb.append(ch);
            }
        }
        String newName = sb.toString();
        // no space at end is allowed
        newName = newName.trim();

        // win doesn't allow dots at the end
        if (newName.endsWith(".")) {
            newName = newName.substring(0, newName.length() - 1);
        }

        // reserved words for windows
        String[] reservedWindows = {"CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8",
                "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"};

        for( String reservedWin : reservedWindows ) {
            if (newName.equals(reservedWin)) {
                newName = newName + "_";
                break;
            }
        }

        return newName;
    }
1077868
public static String getExtension(String filename)
   {
      int index = filename.lastIndexOf('.');

      if (index >= 0)
      {
         return filename.substring(index + 1);
      }

      return "";
   }
1237876
public static String getExtension(File f) {
        String ext = null;
        
        String name = f.getName();
        int i = name.lastIndexOf('.');

        if (i > 0 &&  i < name.length() - 1) {
            ext = name.substring(i+1).toLowerCase();
        }
        
        return ext;
    }
597255
public String getFileName(String originalFileName) {

        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_targetFileName)) {
            return m_targetFileName;
        } else if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_targetFileNamePrefix)) {
            return m_targetFileNamePrefix + originalFileName;
        } else {
            return originalFileName;
        }
    }