FilenameUtils是apache common io中一个独立的工具类,对其他没有依赖,看其源代码的import即可知道。

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Stack;

这个类的目标是:

When dealing with filenames you can hit problems when moving from a Windows
 based development machine to a Unix based production machine.
This class aims to help avoid those problems.

我们在看看uml类图;

我们可以注意到,其提供的方法,基本都是静态的,所以,这个类我认为,大部分使用的时候,都不需要实例化,典型的工具类。

而其目标是在windows系统和unix系统之间的文件名转换,因此,最初就是定义了windows和unix系统的文件的分隔符

    public static final char EXTENSION_SEPARATOR = '.';
public static final String EXTENSION_SEPARATOR_STR = Character.toString(EXTENSION_SEPARATOR);
private static final char UNIX_SEPARATOR = '/';
private static final char WINDOWS_SEPARATOR = '\\';
private static final char SYSTEM_SEPARATOR = File.separatorChar;
private static final char OTHER_SEPARATOR; static {
if (isSystemWindows()) {
OTHER_SEPARATOR = UNIX_SEPARATOR;
} else {
OTHER_SEPARATOR = WINDOWS_SEPARATOR;
}
} static boolean isSystemWindows() {
return SYSTEM_SEPARATOR == WINDOWS_SEPARATOR;
}

  这个,判断是否windows的方法很不错。

最新文章

  1. C#邮箱发送验证码
  2. SpringMVC对日期类型的转换
  3. 深入理解JS的delete
  4. 重新初始化RAC的OCR盘和Votedisk盘,修复RAC系统
  5. http://www.cnblogs.com/softidea/p/5631763.html
  6. [CLR via C#]18. Attribute
  7. Android AIDL使用详解
  8. Eclipse 常用设置
  9. 网站seo新手快速提升自己的技巧
  10. MyBatis 拦截器 (实现分页功能)
  11. 腾讯2014在广州站实习生offer经验(TEG-开发背景)
  12. 使用PowerDesigner画ER图详细教程
  13. linq使用日记
  14. Java复习2.程序内存管理
  15. jmeter接口测试-GET请求路径中包含特殊字符或中文导致Response400报错
  16. Presto集群部署和配置
  17. Spring Cloud构建微服务架构(五)服务网关
  18. MSSQL 数据库 buildindex 出错
  19. 分布式缓存技术redis系列(四)——redis高级应用(集群搭建、集群分区原理、集群操作)
  20. 手工生成AWR报告方法记录

热门文章

  1. DJango跨域中间键
  2. 简洁好看的form样式收藏
  3. loj2174 「FJOI2016」神秘数
  4. centos使用--软件启动关闭等操作的命令
  5. 【Lowest Common Ancestor of a Binary Tree】cpp
  6. Python列表深浅复制详解
  7. jmeter之录制控制器与代理的使用
  8. jmeter察看结果树响应数据中文乱码解决办法
  9. pdb在python程序中应用
  10. Ubuntu系列问题