• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to i save add the contents of the file to StringBuffer?

 
Tran Tuan Hung
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an html file, i have read it, so for now i would to add the contents to
StringBuffer (read each of character then add to buffer), please suggest me
Thanks a lot!
Best regard,
 
Srikanth Ramu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use toCharArray() of String class and append() methods of StringBuffer class.

For more details:

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/StringBuffer.html
[ April 15, 2007: Message edited by: Srikanth Ramu ]
 
Tran Tuan Hung
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for suggest, i have successed for that:
I have done it following:
FileReader fr = new FileReader("Test.html");
BufferedReader br = new BufferedReader(fr);
StringBuffer sb = new StringBuffer();
String line = br.readLine();
try {
while (line!= null) {
sb.append(line).append("\\n");
line = br.readLine();

But now, i would like to deleted tags script and contents on an file html
The detail of the problem as following:
Please help me at here, Thanks you very much
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic