public class StringSplit {
public
static void main(String[] args) {
String
assetClasses = "name = Gold: price = Stocks:icome = Fixed :********";
assetClasses.replace("*",
"");
String[]
splits = assetClasses.split(":");
HashMap<String,
String> hash = new HashMap<String, String>();
System.out.println("splits.size:
" + splits.length);
for
(String asset : splits) {
if
(asset.indexOf("=") != -1) {
String[]
splitstwo = asset.split("=");
//if
((splitstwo.length == 2))
hash.put(splitstwo[0],
splitstwo[1]);
for
(String splitasset : splitstwo) {
System.out.println(splitasset);
}
}
System.out.println(asset);
System.out.println(hash);
}
}
}
No comments:
Post a Comment