cancel
Showing results for 
Search instead for 
Did you mean: 

StringBuffer Encoding and parse to jco

Former Member
0 Kudos

1)

byte[] message=outMail.getMessage();

String msg=new String(message,"UTF-8");

System.out.println("msg");

String have limited size();

if i want to change to StringBuffer..how do i encode this....

StringBuffer sb = new StringBuffer();

2)

byte[] message=outMail.getMessage();

String msg=new String(message,"UTF-8");

inputTable.setValue(msg,"CONTE");

when i set my content to "cba" it will come with ######### at behind

when i return my result to the JCO....

it will be like this

Content: cba ######################

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

yzme,

1. Create String first as you do, then use StringBuffer sb = new StringBuffer(msg);

2. Seems that you are using wrong byte encoding, i.e. the content of message is not UTF-8 encoded.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

for instance i receive from JCO...


if (input2.getNumRows() > 0) {
for (int i = 0; i < input2.getNumRows(); i++) {
input2.setRow(i);
strContent.append(input2.getString("CONTE")).append("rn");
}
System.err.println(strContent.toString());
}

//store it in bytes in db
outMailBean.setMessage(strContent.toString().getBytes());

after that i will parse to jco after successful send the mail...

byte[] message=outMailBean.getMessage();

String msg=new String(message,"ISO-8859-1");

StringBuffer sb=new StringBuffer(msg);

how stringbuffer going to separates into several lines using last index of to determines the line of content...

Table structure

emailid lineno content

1001 1 hallo

1001 2 how r u

Former Member
0 Kudos

yzme,

<i>how stringbuffer going to separates into several lines using last index of to determines the line of content...</i>

No offence -- but could you repeat this in English?

Also make sure that you are using same encoding with <i>strContent.toString().getBytes()</i> and <i>String msg=new String(message,"ISO-8859-1")</i>. In your case use getBytes("ISO-8859-1")

VS

Former Member
0 Kudos

1)

String msg=new String(message,"UTF-8") is wrong

you telling me that

should be

String msg=new String(message,"ISO-8859-1")

izzit...

2)

previously i do like this

sb.append("hallo \r\n");

sb.append("you there \r\n");

strContent = sb.toString().getBytes("ISO-8859");

sb will parse to another method for further processing...

if i have a StringBuffer

how do i break it into several lines when it meet '\r\n'

possible ??

TLINENO Content

1 Hallo

2 You there

Message was edited by:

yzme yzme

Message was edited by:

yzme yzme

Former Member
0 Kudos

instead of using buffer i am using String[] to split ....