in ho utilizzato questo metodo:
public static String replaceToken( String buffer , String token , String newData ) {
// 0) the result is prepared
String resultString = buffer ;
// 1) continue if valid token
if ( !isEmptyString( token ) ) {
int tokenLen = token.length() ;
int tokenIndex = -1 ;
// 2) continue if valid buffer
if ( !isEmptyString( buffer ) ) {
tokenIndex = buffer.indexOf( token ) ;
// 3) continue if valid index
if ( tokenIndex >= 0 ) {
// 4) adjust newData if not meaningful
if ( isEmptyString( newData ) ) {
newData = new String( "" ) ;
}
resultString = buffer.substring( 0 , tokenIndex ) +
newData +
buffer.substring( tokenIndex + tokenLen ) ;
}
}
}
return resultString ;
}