class IrisFileName {

   public static String clean(String fileName, String invalidCharReplacement) {
      if (fileName == null) return null;

      fileName = fileName.trim();

      StringBuilder cleanName = new StringBuilder();
      int len = fileName.codePointCount(0, fileName.length());
      for (int i = 0; i < len; i++) {
         int c = fileName.codePointAt(i);
         if (Arrays.binarySearch(INVALID_CHARS, c) < 0) {
            cleanName.appendCodePoint(c);
         } else {
            cleanName.append(invalidCharReplacement);
         }
      }
      return cleanName.toString();
   }

}