// 得到随机的n个字符
public static String randomStr(int n) {
String str1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
String str2 = "";
int len = str1.length() - 1;
double r;
for (int i = 0; i < n; i++) {
r = (Math.random()) * len;
str2 = str2 + str1.charAt((int) r);
}
return str2;
}
public static String to2b(long num10) {
long temp = num10;
String result1 = "";
while (temp > 0) {
result1 = String.valueOf(temp % 2) + result1;
temp = temp / 2;
}
return result1;
}
public String to10b(String num2) {
int temp = 0;
for (int i = 0; i < num2.length(); i++) {
temp = (temp * 2)
+ Integer.parseInt(String.valueOf(num2.charAt(i)));
}
return String.valueOf(temp);
}
public String getDivide(int a, int b) {
String res = "0";
if (b != 0 && a != 0) {
res = (a * 100 / b) + "%";
}
return res;
}
public static boolean isEmail(String strEmail) {
String temp = new String(strEmail);
boolean re = false;
String ss = "@";
int m = 0;
int n = 0;
for (int i = 0; i < temp.length(); i++) {
if (temp.charAt(i) == ss.charAt(0)) {
m = m + 1;
n = i;
}
}
String kk = ".";
int k = 0;
for (int i = 0; i < temp.length(); i++) {
if (temp.charAt(i) == kk.charAt(0)) {
k = i;
}
}
if ((m == 1) && n > 0 && (n < temp.length() - 1) && k > n + 1) {
re = true;
}
return re;
}