用substring(0,n)来才分1-70个字符,然后在才分70-140个字符,依次类推

解决方案 »

  1.   

    例:String.split("//");
    得到一个String[]数组
      

  2.   

    ex:
    public class boy{
    public static void main(String[] agag){
    int k=0;                 //定义现在的位置
    int count;               //定义截取多少次
    int n=3;                 //每次提取的字符串长度
    String s="hello world";
    int len=s.length();      //得到字符串长度
    count=(len%n==0)?(len/n):(len/n+1);
    for(int i=0;i<count;i++){
    System.out.println(s.substring(k,n));
    k+=3;
    n+=3;
    if(n>len){
    n=len;
    }
    }
    }
    }
      

  3.   

    String portStr;
    while(allStr.length()>70)
    {
      portStr = allStr.substring(0,70);
      send(portStr);
      allStr  = allStr.substring(70);
    }
    send(allStr);