public static String fileNameFromString ( final String text ) { String value = text . replace ( ' ' , ' ' ) ; if ( value . length ( ) < 48 ) { return value ; } return value . substring ( 0 , 47 ) ; }
This method takes a string and converts it into a filename by replacing any spaces with underscores and then also truncating it if it is over a certain length . At the time of the writing of this comment that was 48 characters which was chosen by pulling a number out of my brain .