Q:

how to insert '*' before 'S' and '*' after 'S' in StringBuffer java

How to insert * before S and * after S
StringBuffer Java?
StringBuffer textInFile= new StringBuffer ("Stanford ");
public void convertToPTD(PlainTextDocument ptd)
    {

            if(ptd.textInFile.charAt(i)=='S')
{
        ptd.textInFile.......???
        }
            System.out.println(ptd.textInFile);

        return;

    }

A:

Use the .replace method. An example:
char c = '*';
String s = "S";
String str = "Stanford";
String rep = str.replace(s, c + s + c);

