io.afu.utils.AfuUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of utils Show documentation
Show all versions of utils Show documentation
RffanLAB Utils For Many Way use
package io.afu.utils;
import io.afu.utils.datetime.DateUtils;
import io.afu.utils.datetime.TimeUtils;
import io.afu.utils.encryption.DESEncrypter;
import io.afu.utils.encryption.DESFileEncryption;
import io.afu.utils.encryption.Md5Encryption;
import io.afu.utils.files.FileUtils;
import io.afu.utils.http.Downloader;
import io.afu.utils.http.Request;
import io.afu.utils.os.RunComand;
import io.afu.utils.os.path.PathUtils;
import io.afu.utils.pdf.PDFUtils;
import io.afu.utils.string.StringUtils;
import java.text.SimpleDateFormat;
import java.util.*;
public class AfuUtil {
public static void main(String[] args){
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" );
// try {
// Date theData = simpleDateFormat.parse("2019-05-25 08:56:21");
// Calendar c = Calendar.getInstance();
// c.setTime(theData);
// c.add(Calendar.DAY_OF_MONTH, 1);
// Date orderDate = c.getTime();
// Date date = simpleDateFormat.parse("2019-05-26 09:00:41");
// if(orderDate.before(date)){
// System.out.println(simpleDateFormat.format(date));
// System.out.println(String.format("CT0012滞纳金或自费金额不一致:签约ID【%s】,orderNo【%s】"));
// }
// }catch (Exception e){
//
// }
// System.out.println(FileUtils.getFileSuffixSubstringWay("rffanlab.jpg"));
System.out.println(StringUtils.getRootDomain("io.afu.io"));
}
public static void testSortByAscii(){
Map theStringMap = new HashMap<>();
theStringMap.put("a","23333");
theStringMap.put("b","324523452");
theStringMap.put("0","bh2ui3b");
String orderPatams = CommonUtils.sortMapByAsciiToString(theStringMap);
System.out.println(orderPatams);
}
public static void getToday(){
String date = DateUtils.getTodayByFormat("yyyyMMddhhmmss");
System.out.println(date);
}
public static void downloadFileAndConvertToImg(String url) throws Exception {
String fileName = FileUtils.getFileNameByUrl(url);
String savePath = "D:/tmp/"; // 保存pdf的临时目录
String realPath = savePath + fileName;
String imgSavePath = "D:/tmp/"; // 图片保存目录
try {
Downloader.d(url,realPath);
try {
PDFUtils.convertToImg(realPath,imgSavePath);
}catch (Exception e){
// PDF 转换异常处理
}
}catch (Exception e){
// 异常处理
}
}
public static void downloadFile(){
try {
Downloader.d("http://101.69.143.1:8677/aisinotest/aisinoOffic/valid/0972520718-81106033.pdf?AWSAccessKeyId=AK0G6JTWBQAUHED7CA4X&Expires=2145888000&Signature=osUASMkVUd1CWqcz5p%2FCqCS6RiQ%3D","D:\\tmp\\1505905380517992521.pdf");
}catch (Exception e){
e.printStackTrace();
}
}
public static void getFatherPathForFile(){
String path = PathUtils.getFatherPathForFile("D:\\tmp\\");
System.out.println(path);
}
public static void pdfConverter(){
String pdf = "D:\\tmp\\6073500118-81106033.pdf";
try {
PDFUtils.convertToImg(pdf,"D:\\tmp\\");
}catch (Exception e){
}
}
public static void makeGetUrlTest(){
try {
Map params= new HashMap();
params.put("q","百度");
String result = Request.makeGetUrl("io/afu/utils/http","www.google.com","/help",params);
System.out.println("args = [" + result + "]");
}catch (Exception e){
}
}
public static void useHttpGetRequest(){
try {
String content = Request.
createDefault().
setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36").
get("https://www.togit.cc");
System.out.println("args = [" + content + "]");
}catch (Exception e){
e.printStackTrace();
}
}
public static void useHttpPostRequest(){
}
}