static String sanitizeFileName(String name){
  StringBuffer buffer=new StringBuffer(name.length());
  for (int i=0; i < name.length(); i++) {
    int codePoint=name.codePointAt(i);
    char character=name.charAt(i);
    if (Character.isLetterOrDigit(character) || codePoint > 127 || isSpecialFat32(character)) {
      buffer.appendCodePoint(codePoint);
    }
 else {
      buffer.append("_");
    }
  }
  String result=buffer.toString();
  return result.replaceAll("_+","_");
}

static String sanitizeFileName ( String name ) { StringBuffer buffer = new StringBuffer ( name . length ( ) ) ; for ( int i = 0 ; i < name . length ( ) ; i ++ ) { int codePoint = name . codePointAt ( i ) ; char character = name . charAt ( i ) ; if ( Character . isLetterOrDigit ( character ) || codePoint > 127 || isSpecialFat32 ( character ) ) { buffer . appendCodePoint ( codePoint ) ; } else { buffer . append ( "_" ) ; } } String result = buffer . toString ( ) ; return result . replaceAll ( "_+" , "_" ) ; }
sanitizes the name as a valid fat32 filename . for simplicity , fat32 filename characters may be any combination of letters , digits , or characters with code point values greater than 127 . replaces the invalid characters with " _ " and collapses multiple " _ " together .
