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

 

有时候数据库读出来的名字无法再本地创建文件,需要去掉非法字符。

 

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

    private static Pattern FilePattern = Pattern.compile("[\\\\/:*?\"<>|]");
    public static String filenameFilter(String str) {
        return str==null?null:FilePattern.matcher(str).replaceAll("");
    }
--------------------- 
作者:xiejx618 
来源:CSDN 
原文:https://blog.csdn.net/xiejx618/article/details/17471819 
版权声明:本文为博主原创文章,转载请附上博文链接!

相关文章:

  • 2021-06-11
  • 2022-12-23
  • 2021-06-27
猜你喜欢
  • 2022-12-23
  • 2021-08-17
  • 2022-02-11
  • 2021-09-09
  • 2022-12-23
  • 2021-10-26
相关资源
相似解决方案