Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/02/2010, 02:30
raulredon
 
Fecha de Ingreso: julio-2009
Mensajes: 3
Antigüedad: 14 años, 9 meses
Puntos: 0
Respuesta: Sustitución de carárter "?"

Buenos días,

ya encontré la solución, consiste en definir unos métodos que actúan en lugar de los replace de java para caracteres especiales:

private String replaceAllString(String strOrig, String strFind, String strReplace) {
if(strOrig == null) {
return null;
}
StringBuffer sb = new StringBuffer(strOrig);
String toReplace = "";
if (strReplace == null) toReplace = "";
else toReplace = strReplace;

int pos = strOrig.length();
while (pos > -1) {
pos = strOrig.lastIndexOf(strFind, pos);
if (pos > -1) sb.replace(pos, pos+strFind.length(), toReplace);
pos = pos - strFind.length();
}
return sb.toString();
}

private String replaceFirstString(String strOrig, String strFind, String strReplace) {
if(strOrig == null) {
return null;
}
StringBuffer sb = new StringBuffer(strOrig);
String toReplace = "";
if (strReplace == null) toReplace = "";
else toReplace = strReplace;

int pos = strOrig.length();
while (pos > -1) {
pos = strOrig.lastIndexOf(strFind, pos);
if (pos > -1) {
sb.replace(pos, pos+strFind.length(), toReplace);
return sb.toString();
}
pos = pos - strFind.length();
}
return sb.toString();
}