apache.commons.io学习笔记

最近在学commons.io,记录如下:

commons.io包含几个package:


让顺序来,先学习第一个包。


1. FileSystemUtils类提供一些静态的工具方法,例如查看磁盘的freespace。实现是和操作系统os相关,例如window下通过进程执行命令行下dir操作,通过截取最后的数字部分返回得到。

2. FilenameUtils是和文件名(路径)相关的类,可以区分转换windows或者unix的分隔符“/""\\";有normalize方法用于处理//./../。concat将路径和基本路径连接,再调用normalize。还有directonaryContains判断两个两个路径是否包含。

另外包含一些对下面的处理:主要是get方法

the prefix - C:\

the path - dev\project\

the full path - C:\dev\project\

the name - file.txt

the base name - file

the extension - txt 

3. IOcase类大小写是否敏感,主要用于比较时候的一个标准。

4. ThreadMonitor类主要实现一个定时器线程,实现runnable接口,控制其他线程时,设为daemon。

    public static Thread start(Thread thread, long timeout) {
        Thread monitor = null;
        if (timeout > 0) {
            ThreadMonitor timout = new ThreadMonitor(thread, timeout);
            monitor = new Thread(timout, ThreadMonitor.class.getSimpleName());
            monitor.setDaemon(true);
            monitor.start();
        }
        return monitor;
    }
5. FileDeleteStrategy类如其名,删除策略,normal or force.删除会用到下面的类。

6. FileUtils类

这个类负责文件的一些主要操作,读写增删等等;



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值