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 }
}
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 }
}
解决方案 »
- java.lang.StackOverflowError 怎么办
- json转javabean的问题。
- 简单小程序奇怪现象,大家来看看
- static final会提高效率吗
- 模拟书上做的QQ界面,怎么点击左边list没反应啊
- 关于JXTA中MessageImpl类和MessageElementImpl类的问题
- 本人日语2级 一年java开发经验 能在大连找到多少钱的工作
- 我是一个Java菜鸟,请教高手
- 强烈CSDN建议开《操作系统开发》论坛!
- 有关异常抛出的问题。。。。>>>>>>>>>>>
- 用JAVA怎么实现GB码到BIG5的转换?
- 哪里可以看到Weblogic的在线文档?请给出具体连接,急急急
2, 是的, 的参数意思在文档中写得很明白呀,
就是保留住这个标记的最大的 buffer 长度,
好像是可以重复读对吧?另外我这个帖子问题还没有完全解决,等解决完了一并给分,呵呵,别急请大家帮助回答一下关于那个(int 。。)的问题,嘿嘿
contentReader.reset() ;
就OK啦
Reset the stream to the most recent , or to the beginning of the string if it has never been ed.