Skip to main content

corrupted string

No replies
oliver_block
Offline
Joined: 2007-10-24
Points: 0

Hello forum,

I was facing some problems when copying a string. My MIDlet was receiving it over HTTP and delivered it to a function as argument. No problems so far.

The first problem occured when the string was copied to a String buffer as follows:

public static String parseString(String s) {

StringBuffer str = new StringBuffer( s.trim() );

}

str already contained a corrupted 'String'. After changing that line to

StringBuffer str = new StringBuffer( s );

solved the problem.

Later in the function I was again copying the StringBuffer content to some String variable . This did again produce a corrupted String.

String tmp = str.toString();

I did not solve the problem so far. Right now it seems to be the best way to really copy the string character by character. But as I did not use JavaME very much in the past, I'd like to ask you before, if I just missed something. The String contains some vCalendar objects as defined in RFC2445.

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//my thing// v0.1//EN
BEGIN:VEVENT
DTSTAMP:20071020T015654
DTSTART:20071102T083000
DTEND:20071102T093000
LOCATION:Testort
SUMMARY:Testtermin 1
DESCRIPTION:Testbemerkung
COMMENT:The only purpose of this comment is to have some long li
nes that are to be folded.
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20071020T033525
DTSTART:20071109T113000
DTEND:20071109T133000
LOCATION:Testort 2
SUMMARY:Testtermin 2
DESCRIPTION:Testbemerkung
COMMENT:The only purpose of this comment is to have some long li
nes that are to be folded.
END:VEVENT
END:VCALENDAR

Please note that the line endings are CRLF (US-ASCII 13 followed by US-ASCII 10)

The Problems always occured at the end of the whole thing between the last END:VEVENT and the final END:VCALENDAR (which is also followed by a CRLF).
The END:VCALENDAR was sometimes completely missing sometimes there appeared the final R followed be a \n

Is there any length limit which I've overseen?

TIA!

Best Regards,

Oliver