public static String filenameEncode(String string){
  if (string != null) {
    string=string.replaceAll(ILLEGAL_FILENAME_CHARS_REGEX,"");
    if (string.length() > 255) {
      string=string.substring(0,255);
    }
  }
  return string;
}

public static String filenameEncode ( String string ) { if ( string != null ) { string = string . replaceAll ( ILLEGAL_FILENAME_CHARS_REGEX , "" ) ; if ( string . length ( ) > 255 ) { string = string . substring ( 0 , 255 ) ; } } return string ; }
encodes the given string by removing chars which are illegal on most file systems .
