Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Software (http://www.velocityreviews.com/forums/f6-software.html)
-   -   Urgent in JAVA (http://www.velocityreviews.com/forums/t540638-urgent-in-java.html)

gaurav_kant 09-28-2007 03:07 PM

Urgent in JAVA
 
i have to tokanoze a string

String longString = "name|manish|kumar|malkoti,company|Nucles|Software |EPL,profession|Senior|Programmer";

in this format

name = manishkumar malkoti
company=nucleussoftwareEPL
profession=SeniorProgrammer


my logic is :

String st[] = longString.split(",");
for (int i = 0; i < st.length; i++) {
System.out.println(st[i]);
}

for (int i = 0; i < st.length; i++) {

String str = st[i];
String tmp[]= str.split("|");
for (int j = 1; j < tmp.length; j++) {
System.out.println(tmp[j]);
}
break;


}



but its out put is :

name|manish|kumar|malkoti
company|Nucles|Software|EPL
profession|Senior|Programmer
n
a
m
e
|
m
a
n
i
s
h
|
k
u
m
a
r
|
m
a
l
k
o
t
i


please help:heeeelll:

brishu 11-08-2007 02:41 AM

dude try this code ... this gives you what you want ... it doesn't look that good ... but i think sumthin in Java makes it so that you cant replace ("|")s i tried and it gives you what you want .... if there are 2 many spaces then you can Just delete the space infront of the string;





String longString = "@ name = manish @ kumar @ malkoti,@ company = Nucles @ Software @ EPL,@ profession = Senior @ Programmer";

String st[] = longString.split(",");
for (int i = 0; i < st.length; i++) {
System.out.println(st[i]);
}

for (int i = 0; i < st.length; i++) {

String str = st[i];
String tmp[]= str.split("@");
for (int j = 1; j < tmp.length; j++) {
System.out.print (tmp[j]);
}
System.out.print ("\n");
}


All times are GMT. The time now is 01:10 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.