java 转义字符的问题
在sql server cont(text类型)字段中存在字符串
<table height= "400 " cellspacing= "0 " bordercolordark= "#ffffff " width= "95% " bordercolorlight= "#000000 " border= "1 "> ....................
现要求读出cont的值并 将 "转为 \ "
怎么在java实现或者用sql 实现
我的方法:java实现
String cont=new String(rs.getObject( "cont ").toString().getBytes( "ISO8859-1 "), "gb2312 ");
cont=pub.rep(cont, "\ " ", "\\ "\ "); //这里怎么写
jdk1.5 自己写的替换函数
public String rep(String str,String ca,String rp)
{
//str是原字符串,ca是要替换的字符串,rp是替换的字符串
int m,n,st;
m = n = st = 0;
n = str.length() -1;
StringBuffer sbf = new StringBuffer(str);
for ( m=0 ; m < n ; m++)
{
st = str.indexOf(ca,m);
if (st > -1)
{
sbf.replace(st,st+ca.length(),rp);
m = m + ca.length()-1;
str = sbf.toString();
n = str.length()-1; &n