public static boolean isValidName(String text)
{
Pattern pattern = Pattern.compile(\"^[^/./\\\\:*?\\\"<>|]+$\");
Matcher matcher = pattern.matcher(text
Not sure how to implement it in Java (either Regex or own method). But, Windows OS has the following rules to create file/directory in the file system:
So, the program needs to stick with these rules. Hope, it covers the validation rules for your question.