public static void main(String[] args) {
String a = "(id,created,employee(id,firstname," +
"employeeType(id), lastname),location)";
StringTokenizer tok = new StringTokenizer(a, "(), ");
System.out.println("StringTokenizer example");
while (tok.hasMoreElements()) {
String b = (String)tok.nextElement();
System.out.println(b);
}
System.out.println("Split example");
String[] array = a.split("(),");
for (String ii: array) {
System.out.println(ii);
}
}
}
Outputs
StringTokenizer example
id
created
employee
id
firstname
employeeType
id
lastname
location
Split example
(id
created
employee(id
firstname
employeeType(id)
lastname)
location)
You can add the hyphens.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…