Replacing illegal character in fileName

后端 未结 7 1929
情书的邮戳
情书的邮戳 2020-12-24 10:39

In Java, I\'ve a File-Name-String. There I want to replace all illegal Characters with \'_\', but not a-z, 0-9, -,. and <

7条回答
  •  攒了一身酷
    2020-12-24 10:56

    If you are looking for options on windows platform then you can try below solution to make use of all valid characters other than "\/:*?"<>|" in file name.

    fileName = fileName.replaceAll("[\\\\/:*?\"<>|]", "_");
    

提交回复
热议问题