• 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>

    ————————————————
    版权声明:本文为CSDN博主「yunshouhu」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/earbao/java/article/details/46832853

  • 相关阅读:
    获取视频文件格式信息的工具方法
    springboot中多线程中使用MultipartFile进行异步操作报错,系统找不到指定的文件
    java获取本机IP
    Java获取本机ip和服务器ip
    使用 IntraWeb (45) 活用 IntraWeb
    使用 IntraWeb (44) 测试读取 SqLite (三)
    使用 IntraWeb (43) 测试读取 SqLite (二)
    使用 IntraWeb (42) 测试读取 SqLite (一)
    使用 IntraWeb (41) 数据控件速查
    使用 IntraWeb (40) 自定义 Session 数据
  • 原文地址:https://www.cnblogs.com/telwanggs/p/13116510.html
走看看 - 开发者的网上家园