You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package com.jingcheng.template.service.impl;
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class Test {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
int a = 1;
|
|
|
|
int b = 2;
|
|
|
|
int num=a+(int)(Math.random()*(b-a+1));
|
|
|
|
System.out.println(num);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getStringByEnter(int length, String string) {
|
|
|
|
for (int i = 1; i <= string.length(); i++) {
|
|
|
|
try {
|
|
|
|
if (string.substring(0, i).getBytes("GBK").length > length) {
|
|
|
|
return string.substring(0, i - 1) + "\n" +
|
|
|
|
getStringByEnter(length, string.substring(i - 1));
|
|
|
|
}
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
}
|