aspose file tools*
The moose likes Beginning Java and the fly likes How to i save add the contents of the file to  StringBuffer? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to i save add the contents of the file to  StringBuffer?" Watch "How to i save add the contents of the file to  StringBuffer?" New topic
Author

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

Tran Tuan Hung
Ranch Hand

Joined: Apr 08, 2007
Posts: 59
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

Joined: Feb 20, 2007
Posts: 76
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

Joined: Apr 08, 2007
Posts: 59
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to i save add the contents of the file to StringBuffer?