on 04-25-2007 8:33 AM
byte[] message=outMail.getMessage();
String msg=new String(message,"UTF-8");
System.out.println("msg");
if i want to change to StringBuffer..how do i encode this..
StringBuffer sb = new StringBuffer();
Hi,
I am not sure what you meant, but would this work?
byte[] message=outMail.getMessage();
String msg=new String(message,"UTF-8");
StringBuffer sb = new StringBuffer(msg);
Thanks
Sajesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this:
import java.io.*;
...
byte[] message = outMail.getMessage();
// set up an InputStream and convert to a character Reader
InputStream in = new ByteArrayInputStream(message);
Reader reader = new InputStreamReader(in, "UTF-8");
// now copy the Reader's content to a Writer
Writer writer = new StringWriter();
char[] buf = new char[4096];
int len;
while ((len = reader.read(buf)) >= 0)
writer.write(buf, 0, len);
// and finally get the StringBuffer from the Writer
StringBuffer sb = writer.getBuffer();
Regards,
Jens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.