日期:2014-05-20 浏览次数:20613 次
String as = "0005123450003123000812345678"; while (as.length()>0){ int strCount=Integer.valueOf(as.substring(0, 4)); String res=as.substring(4, 4+strCount); //out print your string System.out.println(res); as=as.substring(4+strCount, as.length()); }
------解决方案--------------------
public static void main(String[] args){ String str = "0005123450003123000812345678"; while(str.length() > 0){ int len = Integer.parseInt(str.substring(0,4)); String sub = str.substring(4,4+len); System.out.println(sub); str = str.substring(4+len); } }
------解决方案--------------------
String strs="0005123450003123000812345678";
while(strs.length() > 0){
int str1=Integer.parseInt(strs.substring(0,4));
System.out.println(strs.substring(0,str1+4));
strs=strs.substring(str1+4);
}
红色部分 看您是否需要前面的'000'