java简单调用
public void split(StringBuffer sb) {
String str = sb.toString();
String subStr = str.substring(str.indexOf("!") + 1, str.length());
String[] outStr = subStr.split("!");
for (int i = 0; i < outStr.length - 1; i ++) {
//System.out.println(outStr[i]);
String[] innerStr = outStr[i].split("#");
//System.out.println(Arrays.toString(innerStr));
for (int j = 0; j < innerStr.length; j++) {
System.out.println(innerStr[j]);
}
}
}
public void getInnerStr() throws
IOException{
Employee e=new Employee();
Service service=new Service();
}
请问,我怎么把innerStr[0]传给employee.userId
------解决方案--------------------
把split方法的void改为String或String[]
如果是String,则return innerStr[0],
employee.setUserId(service.split());//employee有userid的set方法
如果是String[],则return innerStr;
employee.setUserId(service.split()[0]);