Pratibha Nandwana

Greenhorn
+ Follow
since Mar 03, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Pratibha Nandwana

Hi
Thnaks .. I finally did it like this.. Dot kno ifits gud enough ut it works...


import java.util.HashMap;

public class Test
{

public static void main(String[] args)
{

StringBuffer sb = new StringBuffer("<fieldname>serviceId</fieldname><fieldvalue>Eligibility</fieldvalue><fieldname>serviceId3</fieldname><fieldvalue>Eligibility3</fieldvalue><fieldname>serviceId1</fieldname><fieldvalue>Eligibility1</fieldvalue>");
String message = sb.toString();


String namestartTag = "<fieldname>";
String nameendTag = "</fieldname>";
String valuestartTag = "<fieldvalue>";
String valueendTag = "</fieldvalue>";

int startTagLocation = 0;
int endTagLocation = 0;
int valuestartTagLocation = 0;
int valueendTagLocation = 0;

startTagLocation = message.indexOf(namestartTag);
endTagLocation = message.indexOf(nameendTag);
HashMap h = new HashMap();
while(startTagLocation != -1)
{

String str1 = message.substring(startTagLocation+namestartTag.length(),endTagLocation);
System.out.println("str1-----"+str1);
String str_remain = message.substring(endTagLocation+nameendTag.length());

valuestartTagLocation = str_remain.indexOf(valuestartTag);
valueendTagLocation = str_remain.indexOf(valueendTag);
String str_value = str_remain.substring(valuestartTagLocation+valuestartTag.length(),valueendTagLocation );
message = str_remain.substring( valueendTagLocation+valueendTag.length());
startTagLocation = message.indexOf(namestartTag);
endTagLocation = message.indexOf(nameendTag);


h.put(str1,str_value);

} //while
System.out.println("serviceid" + h.get("serviceId"));

}//metod

}//clas
19 years ago
Hi
Im trying to get the two tokens mode and online but this pgm i wrote is returning me the output o,o. Why?

import java.util.*;

public class Test
{

public static void main (String[] args)
{
StringBuffer sb = new StringBuffer("<fieldname>mode</fieldname><fieldvalue>online</fieldvalue>");
String s = sb.toString();
StringTokenizer st = new StringTokenizer(s,"<fieldname></fieldname><fieldvalue></fieldvalue>");
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}



}


}
19 years ago
Hi
when we write import statemnets should we import only the specific class we want as import package.<the specific class which is to be imported>
or shuld we do import packagename.* ? In latter case will all classes get
imported..Is there any difference between two in case i want only 1 class then which is better?
19 years ago
JVM
Hi
I am unable to understand that what is jvm and why is it called virtual machine ? Also what is meant by loading the class ?
19 years ago