java 按照字符数分解字符串

假设按照50为分解标准

    private LinkedList<String> splitAddress(String address) {
     LinkedList<String > addressList=new LinkedList<>();
        int splitLength = address.length();
        String s = address;
        while (splitLength >= 50) {
            String tmp = s.substring(0, 50);
            addressList.add(tmp);
            s = s.substring(50);
            splitLength = s.length();
        }
        if (splitLength!=0){
        addressList.add(s);
        }
        return addressList;
    }

 

posted @ 2020-08-14 10:12  大哥超帅  阅读(356)  评论(0编辑  收藏  举报