Need to append a String at the Starting or Beginning of a StringBuffer ?

Hi All,

I am having a StringBuffer. for example StringBuffer s = new StringBuffer("kathir");

I like to append a string with the stringbuffer at the starting point.

Input

StringBuffer s = new StringBuffer("kathir");

need to append "raj" before kathir

Output

raj kathir

Is there is any way to do this using StringBuffer. Do we have any functions in StringBuffer which does this ?

Thanks,

J.Kathir

[461 byte] By [jkathira] at [2007-10-3 6:56:22]
# 1
I wonder what the insert() method is for. RTFA
CeciNEstPasUnProgrammeura at 2007-7-15 1:48:21 > top of Java-index,Java Essentials,Java Programming...
# 2
Yep - you can use one of the variants of insert() - look up the Javadocs for StringBuffer. They should always be where you look first.
TimRyanNZa at 2007-7-15 1:48:21 > top of Java-index,Java Essentials,Java Programming...
# 3
> RTFAHi ceci - what does the A stand for? I was thinking J or M
TimRyanNZa at 2007-7-15 1:48:21 > top of Java-index,Java Essentials,Java Programming...
# 4
The append method is what you want.e.gs.append("raj ").append("kathir");Message was edited by: colin_lew
colin_lewa at 2007-7-15 1:48:21 > top of Java-index,Java Essentials,Java Programming...
# 5
> The append method is what you want.> > e.g> > s.append("raj ").append("kathir");> > Message was edited by: > colin_lewNo, the other answers in this thread are correct. Using append is wrong.Kaj
kajbja at 2007-7-15 1:48:21 > top of Java-index,Java Essentials,Java Programming...
# 6
> > RTFA> > Hi ceci - what does the A stand for? I was thinking> J or MAPI, maybe?
Martin@Stricenta at 2007-7-15 1:48:21 > top of Java-index,Java Essentials,Java Programming...
# 7
> API, maybe?Yep, I'm sure you're right.Thanks,Tim
TimRyanNZa at 2007-7-15 1:48:21 > top of Java-index,Java Essentials,Java Programming...
# 8
> > API, maybe?> > Yep, I'm sure you're right.He is. Some also say RTFAPI.
CeciNEstPasUnProgrammeura at 2007-7-15 1:48:21 > top of Java-index,Java Essentials,Java Programming...