|
|
@ -17,10 +17,7 @@ import java.io.*; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.net.URL; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
public class OtherTest { |
|
|
@ -140,70 +137,53 @@ public class OtherTest { |
|
|
|
System.out.println(split); |
|
|
|
System.out.println(split1); |
|
|
|
|
|
|
|
} |
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// * 发送https请求
|
|
|
|
// *
|
|
|
|
// * @param requestUrl 请求地址
|
|
|
|
// * @param requestMethod 请求方式(GET、POST)
|
|
|
|
// * @param postStr 提交的数据
|
|
|
|
// * @return String(Json)
|
|
|
|
// */
|
|
|
|
// @Test
|
|
|
|
// public void test9(String requestUrl, String requestMethod, String postStr) throws Exception {
|
|
|
|
//
|
|
|
|
// requestUrl = "http://localhost:8001/file/query";
|
|
|
|
// requestMethod = "POST";
|
|
|
|
// List<Long> files = new ArrayList<>();
|
|
|
|
// files.add(1321760076465311744L);
|
|
|
|
//
|
|
|
|
// postStr = JacksonUtil.beanToJson(files);
|
|
|
|
//
|
|
|
|
// StringBuffer buffer = null;
|
|
|
|
// // 创建SSLContext对象,并使用我们指定的信任管理器初始化
|
|
|
|
// TrustManager[] tm = {new MyX509TrustManager()};
|
|
|
|
// SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");
|
|
|
|
// sslContext.init(null, tm, new java.security.SecureRandom());
|
|
|
|
// // 从上述SSLContext对象中得到SSLSocketFactory对象
|
|
|
|
// SSLSocketFactory ssf = sslContext.getSocketFactory();
|
|
|
|
//
|
|
|
|
// URL url = new URL(requestUrl);
|
|
|
|
// HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
|
|
|
|
// conn.setSSLSocketFactory(ssf);
|
|
|
|
//
|
|
|
|
// conn.setDoOutput(true);
|
|
|
|
// conn.setDoInput(true);
|
|
|
|
// conn.setUseCaches(false);
|
|
|
|
// // 设置请求方式(GET/POST)
|
|
|
|
// conn.setRequestMethod(requestMethod);
|
|
|
|
} |
|
|
|
@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("--------"); |
|
|
|
//
|
|
|
|
// // 当outputStr不为null时向输出流写数据
|
|
|
|
// if (null != postStr) {
|
|
|
|
// OutputStream outputStream = conn.getOutputStream();
|
|
|
|
// // 注意编码格式
|
|
|
|
// outputStream.write(postStr.getBytes("UTF-8"));
|
|
|
|
// outputStream.close();
|
|
|
|
// }
|
|
|
|
// x.sort(Comparator.comparingInt(o -> o.getStuVOList().size()));
|
|
|
|
//
|
|
|
|
// // 从输入流读取返回内容
|
|
|
|
// InputStream inputStream = conn.getInputStream();
|
|
|
|
// InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");
|
|
|
|
// BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
|
|
|
|
// String str = null;
|
|
|
|
// buffer = new StringBuffer();
|
|
|
|
// while ((str = bufferedReader.readLine()) != null) {
|
|
|
|
// buffer.append(str);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // 释放资源
|
|
|
|
// bufferedReader.close();
|
|
|
|
// inputStreamReader.close();
|
|
|
|
// inputStream.close();
|
|
|
|
// inputStream = null;
|
|
|
|
// conn.disconnect();
|
|
|
|
//// return buffer == null ? null : buffer.toString();
|
|
|
|
// System.out.println( buffer == null ? null : buffer.toString());
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
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()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|