Sanitize filename.

@param filename
the filename
@return the sanitized filename
338607
private String sanitizeFilename(final String filename) {
        return filename.replace('/', '_').replace('\\', '_').replace(':', '_').replace('?', '_').replace('&', '_')
                .replace('=', '_').replace(' ', '_');
    }
1211246
public static String makeSafeFilename(String filename) {
        // Replace invalid characters
        for (final Map.Entry<Pattern, String> pair : REPLACEMENT_PAIRS.entrySet()) {
            final Pattern pattern = pair.getKey();
            final Matcher matcher = pattern.matcher(filename);
            filename = matcher.replaceAll(pair.getValue());
        }

        // Make sure the name doesn't violate a Windows reserved word...
        for (Pattern pattern : WINDOWS_INVALID_PATTERNS) {
            if (pattern.matcher(filename).matches()) {
                filename = "uP-" + filename;
                break;
            }
        }

        return filename;
    }
527182
private String getSuffix(String fileName) {

        int index = fileName.lastIndexOf(".");
        if (index > 0) {
            return fileName.substring(index);
        } else {
            return fileName;
        }
    }
1218611
@Pure
	public static String shortBasename(String filename) {
		if (filename == null) {
			return null;
		}
		if (isWindowsNativeFilename(filename)) {
			return shortBasename(normalizeWindowsNativeFilename(filename));
		}

		try {
			return shortBasename(new URL(filename));
		} catch (Exception exception) {
			// No log
		}
		final String normalizedFilename = fromFileStandardToURLStandard(filename);
		int idx;
		int end = normalizedFilename.length();
		do {
			end--;
			idx = normalizedFilename.lastIndexOf(URL_PATH_SEPARATOR_CHAR, end);
		}
		while (idx >= 0 && end >= 0 && idx >= end);
		final String basename;
		if (idx < 0) {
			if (end < normalizedFilename.length() - 1) {
				basename = normalizedFilename.substring(0, end + 1);
			} else {
				basename = normalizedFilename;
			}
		} else {
			basename = normalizedFilename.substring(idx + 1, end + 1);
		}
		idx = basename.indexOf(getFileExtensionCharacter());
		if (idx < 0) {
			return basename;
		}
		return basename.substring(0, idx);
	}
459007
public static String removeExtension(String fileName) {
		final String separator = FILE_SEPARATOR;
		String filename;
		// Remove the path upto the filename.
		final int lastSeparatorIndex = fileName.lastIndexOf(separator);
		if (lastSeparatorIndex == -1) {
			filename = fileName;
		} else {
			filename = fileName.substring(lastSeparatorIndex + 1);
		}

		// Remove the extension.
		final int extensionIndex = filename.lastIndexOf(".");
		if (extensionIndex == -1) {
			return filename;
		}
		fileName = fileName.substring(0, lastSeparatorIndex);
		return fileName + File.separator + filename.substring(0, extensionIndex);
	}
904087
public static String getFileSuffix(String fileName) {
        return fileName.substring(fileName.lastIndexOf(ValueConsts.DOT_SIGN) + 1);
    }
205773
public String toFilename() {
        if (m_filename == null) { // lazily convert, since not always needed
            m_filename = m_normalized.replaceAll(":", "_");
            if (m_filename.endsWith(".")) {
                m_filename =
                        m_filename.substring(0, m_filename.length() - 1) + "%";
            }
        }
        return m_filename;
    }
318641
protected function sanitize($basename)
	{
		$filename = pathinfo($basename, PATHINFO_FILENAME);
		$extension = pathinfo($basename, PATHINFO_EXTENSION);

		$filename = str_replace(' ', '-', $filename);
		$filename = preg_replace('/[^a-z0-9\.\-\_]/i', '', $filename);
		$filename = substr($filename, 0, 100);

		$filename = trim($filename, '-_.') ?: 'no-name';

		return $filename . ($extension ? '.'. $extension : '');
	}
1271987
public static function cleanFilename($filename)
    {
        return preg_replace(
            '/[^A-Za-z0-9_\-]/',
            '_',
            htmlentities(pathinfo($filename, PATHINFO_FILENAME))
        ) . '.' . preg_replace(
            '/[^A-Za-z0-9_\-]/',
            '_',
            htmlentities(pathinfo($filename, PATHINFO_EXTENSION))
        );
    }
821317
@CheckForNull
  public static String sanitize(@Nullable String path) {
    return FilenameUtils.normalize(path, true);
  }
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));
	}
731367
public static String sanitizeBuildName(String buildName) {
        String s = StringUtils.replace(buildName, "/", " :: ");
        return StringUtils.replace(s, "%2F", " :: ");
    }
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)};
    }
625224
public synchronized void setFilename(String filename)
    {
        if (filename!=null)
        {
            filename=filename.trim();
            if (filename.length()==0)
                filename=null;
        }
        
        if (isStarted() && _filename!=null && filename==null)
            _out=null;
        
        _reopen=isStarted() &&
            ((_filename==null && filename!=null)||
             (_filename!=null && !_filename.equals(filename)));
        _filename=filename;

        if (!isStarted() && _filename!=null)
            _out=null;
    }
1211321
private static String toQualifiedClassName(final String fileName) {
        final String replacedSeparators = fileName.replace(File.separatorChar, '.');
        return replacedSeparators.substring(0, replacedSeparators.length() - ".class".length());
    }
1362305
protected static String trimFileExtension(String fileName) {
		if (fileName.lastIndexOf('.') == -1) {
			return fileName;
		}
		return fileName.substring(0, fileName.lastIndexOf('.'));
	}
628764
public static String getFileExt(String fileName) {
        int dotPos = fileName.lastIndexOf('.');
        if (dotPos != -1 && dotPos != fileName.length() - 1) {
            return fileName.substring(dotPos);
        } else {
            return null;
        }
    }