1 Dec 2013

how to do highlight on string in java code

/* how to do highlight on string in java code, java highlight word in string */

here is a sample code

String startTag = "<b><font size='3' color='blue'>";
String startTag1 = "<font size='2' color='blue'>";
String endTag1 = "</font>";
String endTag = "</font></b>";

//here 'al' is arraylist which contains some elements

for(int i1=0;i1<ary1.length;i1++)
{ if(al.contains(ary1[i1].toLowerCase().trim()))
{
//flag=1;
hResult.append(startTag);
hResult.append(ary1[i1]+" ");
hResult.append(endTag);
}
else
{
//flag=flag;
hResult.append(startTag1);
hResult.append(ary1[i1]+" ");
hResult.append(endTag1);
}
}

here print the output.

output:



how to do highlight on string in java code