云守护的专栏

专注于移动安全、游戏安全、逆向安全 ;------------------------- 邮箱:1309521515@qq.com...

Java工具方法hutool 使用备注
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>


阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/earbao/article/details/46832853
个人分类: java
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

Java工具方法hutool 使用备注

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭