public static void main(String[] args) {
String str = "asfdas7fsafds7afsadf7dsafsa7dfdsaf7a";
if(str.length()>7){
String temp = str.substring(0, 7);
while(str.length()>7){
System.out.println(temp);
str = str.substring(7, str.length());
if(str.length() > 7){
temp = str.substring(0, 7);
}else{
temp = str;
}
}
System.out.println(temp);
}else{
System.out.println(str);
}
}
建议再使用StringBuilder来处理一下