**
* 用半角的特殊符号代替全角的特殊符号
* 防止特殊字符在传输参数时出现错误
*
*/
public class ReplaceStrE{
public static String rightToError(String ss){
String strs;
String strs1;
String strs2;
String strs3;
String strs4;
try{
strs = ss.replace('#','#');
}
catch(Exception ex){
return ss;
}
try{
strs1 = strs.replace('"','"');
}
catch(Exception ex){
return strs;
}
try{
strs2 = strs1.replace(' ','&');
}
catch(Exception ex){
return strs1;
}
try{
strs3 = strs2.replace('+','+');
}
catch(Exception ex){
return strs2;
}
try{
strs4 = strs3.replace(''','/'');
}
catch(Exception ex){
return ss;
}
return strs4;
}
}
本文介绍了一个用于将字符串中的全角特殊字符转换为半角字符的Java方法。该方法通过一系列替换操作来确保字符串能在参数传输过程中避免错误。文章详细展示了如何针对不同全角特殊字符进行转换。
470

被折叠的 条评论
为什么被折叠?



