package TestHuTool;
import it.sauronsoftware.cron4j.Scheduler;
import java.io.File;
import com.xiaoleilu.hutool.NetUtil;
import com.xiaoleilu.hutool.RandomUtil;
import com.xiaoleilu.hutool.SecureUtil;
import com.xiaoleilu.hutool.Setting;
import com.xiaoleilu.hutool.Validator;
/**
Java工具方法hutool 使用例子
http://hutool.mydoc.io/
http://hutool.mydoc.io/?t=820
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
System.out.println(NetUtil.localIpv4s());
//System.out.println(NetUtil.isUsableLocalPort(9090));
String charset="utf-8";
System.out.println(RandomUtil.randomString(10));
String source="fuck";
System.out.println(SecureUtil.md5(source, "utf-8"));
System.out.println(SecureUtil.sha1(source, "utf-8"));
String out=SecureUtil.base64(source, "utf-8");
System.out.println(out);
System.out.println(SecureUtil.decodeBase64(out, "utf-8"));
Setting setting=new Setting(new File("d:/cmd.ini"), charset, true);
System.out.println(setting.getString("command.cmd"));
boolean isEmail = Validator.isEmail("loolly@gmail.com");
System.out.println(isEmail);
System.out.println(Validator.isByRegex("需要验证字段的正则表达式", "被验证内容"));
//定时器任务http://hutool.mydoc.io/?t=827
//使用cron4j框架
System.out.println(new File(".").getAbsolutePath());
//CronUtil.setCronSetting("cron4j.setting");
// CronUtil.start();
// Declares the file.
File file = new File("cron4jtab.txt");
// Creates the scheduler.
Scheduler scheduler = new Scheduler();
// Schedules the file.
scheduler.scheduleFile(file);
// Starts the scheduler.
scheduler.start();
// Stays alive for five minutes.
try {
Thread.sleep(5L * 60L * 1000L);
} catch (InterruptedException e) {
;
}
// Stops the scheduler.
scheduler.stop();
}
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TestHuTool</groupId>
<artifactId>TestHuTool</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TestHuTool</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.xiaoleilu</groupId>
<artifactId>hutool</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>it.sauronsoftware.cron4j</groupId>
<artifactId>cron4j</artifactId>
<version>2.2.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
</dependency>
</dependencies>
</project>
————————————————
版权声明:本文为CSDN博主「yunshouhu」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/earbao/java/article/details/46832853