class FileNameValidator {

    public static boolean validate(String filename) {
        if (filename == null) {
            return false;
        }
        Arrays.sort(FILE_NAME_FORBIDDEN_CHARS);
        Arrays.sort(FILE_NAME_ACCEPTED_CHARS);

        for (int i = 0; i < filename.length(); i++) {
            char character = filename.charAt(i);
            if (Arrays.binarySearch(FILE_NAME_ACCEPTED_CHARS, character) >= 0) {
                continue;
            } else if (character < 33 || character > 255 || Arrays.binarySearch(FILE_NAME_FORBIDDEN_CHARS, character) >= 0) {
                return false;
            }
        }
        // Remove the last three positions with ...
        // And check if there are any unwanted path denominators in the name
        if (StringUtils.remove(filename, "...").indexOf("..") > -1) {
            return false;
        }
        return true;
    }

}