import java.io.* ;public class BufferTest {    public static void main(String[] args) {

        String content = "content" ;

        StringBuffer buffer = new StringBuffer("");
        StringReader contentReader = new StringReader(content);        BufferedReader br = new BufferedReader(contentReader);
        String contentLine; try{
        while ((contentLine = br.readLine()) != null) {
            buffer.append(contentLine) ; // output content
        }
} catch(Exception e) {
System.out.println(e) ;
}
        System.out.println(buffer.toString()) ;

// write again
try{
        while ((contentLine = br.readLine()) != null) {
            buffer.append(contentLine);
        }
} catch(Exception e) {
System.out.println(e) ;
}
        System.out.println(buffer.toString()) ; // output content }
}

解决方案 »

  1.   

    sorry, 上面的测试代码有误, 第二次buffer没有清空.测试的结论是第二次buffer什么也没写进去
      

  2.   

    1, 是的.
    2, 是的,  的参数意思在文档中写得很明白呀,
    就是保留住这个标记的最大的 buffer 长度,
      

  3.   

    谢谢snowredfox的热心帮助,
    好像是可以重复读对吧?另外我这个帖子问题还没有完全解决,等解决完了一并给分,呵呵,别急请大家帮助回答一下关于那个(int 。。)的问题,嘿嘿
      

  4.   

    第二次使用时加上
    contentReader.reset() ;
    就OK啦
      

  5.   

    void reset() :
              Reset the stream to the most recent , or to the beginning of the string if it has never been ed.