public static boolean isValidName(String text) { Pattern pattern = Pattern.compile(\"^[^/./\\\\:*?\\\"<>|]+$\"); Matcher matcher = pattern.matcher(text
Well, I think the following method would guarantee a valid file name:
public static boolean isValidName(String text) { try { File file = new File(text); file.createNewFile(); if(file.exists()) file.delete(); return true; } catch(Exception ex){} return false; }
What do you think?