You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
189 lines
5.1 KiB
189 lines
5.1 KiB
package com.ccsens.util;
|
|
|
|
|
|
import cn.hutool.core.util.ImageUtil;
|
|
import lombok.Data;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.junit.Test;
|
|
|
|
import javax.net.ssl.HttpsURLConnection;
|
|
import javax.net.ssl.SSLContext;
|
|
import javax.net.ssl.SSLSocketFactory;
|
|
import javax.net.ssl.TrustManager;
|
|
import javax.script.ScriptEngine;
|
|
import javax.script.ScriptEngineManager;
|
|
import javax.script.ScriptException;
|
|
import java.io.*;
|
|
import java.math.BigDecimal;
|
|
import java.net.URL;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
|
|
@Slf4j
|
|
public class OtherTest {
|
|
|
|
|
|
public static final String REGEX_PHONE = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,1-9]))\\d{8}$";
|
|
|
|
@Test
|
|
public void test2() throws ScriptException {
|
|
String str = "18200000000";
|
|
if (str.matches(REGEX_PHONE)) {
|
|
System.out.println("是手机号");
|
|
} else {
|
|
System.out.println("不是手机号");
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void test3() {
|
|
File file = new File("C:\\Users\\逗\\Desktop\\ABDBBE53630FE09D526858C4A8029873.jpg");
|
|
File file1 = new File("C:\\Users\\逗\\Desktop\\1.jpg");
|
|
File file2 = new File("C:\\Users\\逗\\Desktop\\2.jpg");
|
|
System.out.println(file.length());
|
|
ImageUtil.scale(file,file1,0.5f);
|
|
System.out.println(file1);
|
|
ImageUtil.scale(file1,file2,2);
|
|
}
|
|
@Test
|
|
public void func3(){
|
|
SimpleDateFormat sdf2 = new SimpleDateFormat("MM-dd a");
|
|
String sd2 = sdf2.format(new Date(1605074997152L));
|
|
System.out.println(sd2);
|
|
}
|
|
|
|
@Test
|
|
public void test4() {
|
|
int a = 119;
|
|
int b = 6;
|
|
System.out.println(Math.ceil((float)a/(float)b));
|
|
}
|
|
|
|
|
|
@Test
|
|
public void test5() {
|
|
BigDecimal a = BigDecimal.valueOf(1.255);
|
|
BigDecimal b = BigDecimal.valueOf(1.256);
|
|
BigDecimal aa = a.divide(BigDecimal.valueOf(1),2,BigDecimal.ROUND_HALF_DOWN);
|
|
BigDecimal aa1 = a.divide(BigDecimal.valueOf(1),2,BigDecimal.ROUND_DOWN);
|
|
BigDecimal bb = b.divide(BigDecimal.valueOf(1),2,BigDecimal.ROUND_HALF_DOWN);
|
|
BigDecimal bb1 = b.divide(BigDecimal.valueOf(1),2,BigDecimal.ROUND_DOWN);
|
|
System.out.println(aa + "++++" + bb);
|
|
System.out.println(aa1 + "++++" + bb1);
|
|
}
|
|
@Data
|
|
public static class AA{
|
|
private int a;
|
|
private int b;
|
|
|
|
public AA(int a, int b) {
|
|
this.a = a;
|
|
this.b = b;
|
|
}
|
|
|
|
public AA() {
|
|
}
|
|
}
|
|
@Test
|
|
public void test6() {
|
|
AA a1 = new AA(1,4);
|
|
AA a2 = new AA(2,3);
|
|
AA a3 = new AA(2,2);
|
|
AA a4 = new AA(4,1);
|
|
List<AA> aas = new ArrayList<>();
|
|
aas.add(a3);
|
|
aas.add(a4);
|
|
aas.add(a1);
|
|
aas.add(a2);
|
|
|
|
aas.sort(Comparator.comparingInt(o -> o.a));
|
|
|
|
aas.forEach(aa -> {
|
|
System.out.print(aa.a);
|
|
|
|
});
|
|
System.out.println("");
|
|
aas.forEach(aa -> {
|
|
System.out.print(aa.b);
|
|
});
|
|
|
|
}
|
|
@Test
|
|
public void test7() {
|
|
int a = 0x0A;
|
|
int b = 0x08;
|
|
System.out.println(a << 8 | b);
|
|
|
|
int c = 2568;
|
|
int uc1 = c >> 8;
|
|
int uc2 = c & 0xff;
|
|
System.out.println(Integer.toHexString(uc1));
|
|
System.out.println(Integer.toHexString(uc2));
|
|
|
|
}
|
|
|
|
@Test
|
|
public void test8(){
|
|
System.out.println(Byte.parseByte("-1") & 0xff);
|
|
}
|
|
|
|
@Test
|
|
public void test9(){
|
|
String a = "a,b,c";
|
|
String x = "a";
|
|
|
|
String[] split = a.split(",");
|
|
String[] split1 = x.split(",");
|
|
System.out.println(split);
|
|
System.out.println(split1);
|
|
|
|
}
|
|
@Test
|
|
public void test10(){
|
|
List<StuVO> list1 = new ArrayList<>();
|
|
list1.add(new StuVO("AAA",90));
|
|
list1.add(new StuVO("BBB",150));
|
|
list1.add(new StuVO("CCC",12));
|
|
list1.add(new StuVO("DDD",64));
|
|
list1.add(new StuVO("EEE",5));
|
|
List<StuVO> list2 = new ArrayList<>();
|
|
list2.add(new StuVO("AAA",90));
|
|
list2.add(new StuVO("BBB",150));
|
|
|
|
|
|
StuVO a = new StuVO();
|
|
a.setStuVOList(list1);
|
|
a.setName("aa");
|
|
|
|
StuVO b = new StuVO();
|
|
b.setStuVOList(list2);
|
|
b.setName("bb");
|
|
|
|
List<StuVO> x = new ArrayList<>();
|
|
x.add(a);
|
|
x.add(b);
|
|
|
|
for(int i = 0;i < x.size();i++){
|
|
System.out.println(x.get(i).getName()+" "+x.get(i).getScore());
|
|
}
|
|
System.out.println("--------");
|
|
//
|
|
// x.sort(Comparator.comparingInt(o -> o.getStuVOList().size()));
|
|
//
|
|
//
|
|
|
|
|
|
Collections.sort(x, new Comparator<StuVO>() {
|
|
@Override
|
|
public int compare(StuVO o1, StuVO o2) {
|
|
int i = o2.getStuVOList().size() - o1.getStuVOList().size();
|
|
return i;
|
|
}
|
|
});
|
|
for(int i = 0;i < x.size();i++){
|
|
System.out.println(x.get(i).getName()+" "+x.get(i).getScore());
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|