返回服务器参数
@RestController
public class EnvController {
@RequestMapping("/env")
public ReturnBean env() {
Properties pros = System.getProperties();
Map<String, String> map = new HashMap<String, String>();
if (pros != null && pros.size() > 0) {
Enumeration<Object> enums = pros.keys();
while (enums.hasMoreElements()) {
String key = (String) enums.nextElement();
String value = pros.getProperty(key);
map.put(key, value);
}
}
map.put("单个汉子字节数", "我".getBytes().length + "");
ReturnBean bean = ReturnBean.getSuccessInstance("");
bean.setData(map);
return bean;
}
}
随机生成一个身份证号码
public class sfz {
public static void main(String[] args) {
System.out.println(randowAAc147());
}
public static String randowAAc147() {
String id = "330726" + randowNum(1920, 2018, 4) + randowNum(1, 12, 2) + randowNum(1, 28, 2)
+ randowNum(0, 999, 3);
return getAAc147(id);
}
/**
* 生成一个min-max的随机数,位数为ws位
*/
public static String randowNum(int min, int max, int ws) {
Integer v = new Random().nextInt(max + 1 - min) + min;
String result = v + "";
if (result.length() < ws) {
for (int i = 0; i < ws - result.length(); i++) {
result = "0" + result;
}
}
return result;
}
public static String getAAc147(String aac147) {
char pszSrc[] = aac147.toCharArray();
int iS = 0;
int iW[] = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
char szVerCode[] = new char[] { '1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2' };
int i;
for (i = 0; i < 17; i++) {
iS += (int) (pszSrc[i] - '0') * iW[i];
}
int iY = iS % 11;
String c = String.valueOf(szVerCode[iY]);
return aac147 + c;
}
}
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于