如何将提醒int值转换为字符串(字符)

时间:2016-11-07 13:21:23

标签: java string int string-length mod

如何将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);

1 个答案:

答案 0 :(得分: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));