public static boolean isValidName(String text) { Pattern pattern = Pattern.compile(\"^[^/./\\\\:*?\\\"<>|]+$\"); Matcher matcher = pattern.matcher(text
How about letting the File class do your validation?
public static boolean isValidName(String text) { try { File file = new File(text); return file.getPath().equals(text); } catch(Exception ex){} return false; }