i want output of my java program without whitespaces , my code is -
Source source1=new Source(new URL(sourceUrlString1));
List<Element> temp1 = source1.getElementById("main").getAllElementsByClass("grid_3 alpha");
String line = temp1.toString();
String temps = line.trim();//using this
String temps = line.replaceAll("\\s+","")// or this
if(!temps.isEmpty())
{
sendResponse(resp, "Information for:"+searchWord+":" +temps);
}
When i am using Trim it gives output with lot of space between Information and SATISH
Information for::[
SATISH
JHOTWARA (JAIPUR)
Party:CPI
S/o|D/o|W/o: Om Prakash
Age: 42
When i am using String temps = line.replaceAll("\\s+","")
;
it gives output as:
Information for::[<divclass="grid_3alpha"style='background:khaki;'><h2class="main-title">SatishKumar<fontcolor=greensize=1>(Winner)
ELECTEDFROMBIHARLEGISLATIVEASSEMBLY
<divclass="grid_2alpha">Party:JD(U)<divclass="grid_2alpha">S/o|D/o|W/o:JagdishPrasad<divclass