public static String convertToNonBreakingSpaces(int preSpaces,String s){
  StringBuilder b=new StringBuilder(preSpaces + s.length());
  for (int i=0; i < preSpaces; i++)   b.append('\u00a0');
  b.append(s.replace(' ','\u00a0'));
  return b.toString();
}

public static String convertToNonBreakingSpaces ( int preSpaces , String s ) { StringBuilder b = new StringBuilder ( preSpaces + s . length ( ) ) ; for ( int i = 0 ; i < preSpaces ; i ++ ) b . append ( ' ' ) ; b . append ( s . replace ( ' ' , ' ' ) ) ; return b . toString ( ) ; }
converts all spaces in the string to non - breaking spaces . adds ' prespaces ' number of non - breaking spaces prior to the string .
