0

我已经声明了两个字符串缓冲区,例如,

private StringBuffer buf = new StringBuffer(1024);
private StringBuffer bufRetro = new StringBuffer(1024);

在以下代码中,在 bufRetro = buf 之前,buf 具有适当的填充值。但是,复制后,两者都没有内容。如何从另一个设置一个stringBuffer?谢谢你。

if(this.v_Id){

    buf.append(ch, start, length);

    if (bufType.equals(bufOld)){

        buf = bufRetro.append(buf);

    }

    myParsedXMLDataSet.setId(buf.toString());

    bufOld = bufType;

    bufRetro.delete(0, bufRetro.length());
    bufRetro = buf;

    Log.d("id", buf.toString());

    buf.delete(0, buf.length());
4

1 回答 1

0

如何从另一个设置一个stringBuffer?

怎么样

bufRetro.setLength(0);   // copy content from buf to bufRetro
bufRetro.append(buf);

buf.setLength(0);        // if you want to clear the original one.
于 2012-07-03T13:13:20.380 回答