如何将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);
所以你想把数字字符串"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));