过滤文件名非法字符

为了合理性,过滤文件名非法字符是必须的,果断地要干掉.....

windows现在已知的文件名非法字符有 \ / : * ? " < > |



	private static Pattern FilePattern = Pattern.compile("[\\\\/:*?\"<>|]");
	public static String filenameFilter(String str) {
		return str==null?null:FilePattern.matcher(str).replaceAll("");
	}


你可能感兴趣的:(过滤文件名非法字符)