0

如何将 int 值转换为字符串意味着我的字符串将是 42646 字符其 mod 42600 如何显示和打印这个字符以及如何?

int count = image_length.length(); //count=42646
System.out.println(count);
int mod = count % length; //46
int rem = count - mod; //42600
String rem_value = String.valueOf(rem);
// I want to get string through reminder value 42600 & how
String[] split = rem_value.split("[^a-zA-Z/]", length);

getSaltString();

photoName = randStr + "_IMG.jpg";
StringBuilder stringBuilder = new StringBuilder();

for (int i = 0; i < split.length; i++) {

    url_part = String.valueOf(stringBuilder.append(split[i]));
    new RegisterImageThread(ActivityRegisterUploadPhoto.this).execute(photoName, url_part + i);
}
new RegisterImageThread(ActivityRegisterUploadPhoto.this).execute(photoName, url_part+rem_value);
4

1 回答 1

0

所以你想将数字字符串“42600”拆分为一个数组,对吗?换行:

String[] split = rem_value.split("[^a-zA-Z/]", length);

像这样:

    String rem_value = "42600"; //your rem_value
    int[] split = new int[rem_value.length()];
    for (int i = 0; i < rem_value.length(); i++) {
        split[i] = Character.getNumericValue(rem_value.charAt(i));
    }

    //print the result
    Arrays.stream(split).forEach(s -> System.out.println(s));
于 2016-11-07T13:55:37.060 回答