java File中File.exists() 与 File.isFile()区别?
来源:互联网 发布:3d 打印 切片算法思想 编辑:程序博客网 时间:2024/05/16 08:31
这种区别一般在Linux环境中比较明显。
比如在Linux环境中/dev/null
这个文件是个特殊文件。
使用File.isFile()
方法返回结果是false
使用File.exists()
方法返回结果是true
也就是说如果是我们常见的普通文件,两者是没多少区别的!
区别只在于特殊文件中。
Use File.exists() when dealing with special files like named pipes, sockets or device files.Those are not regular files nor directories nor symlinks so both File.isFile() and File.isDirectory() will return false while File.exists() will return true. For example /dev/null (on Unix compatible OSes) is a device file.Theoretically there may be performance differences visible when processing large amounts of files. This depends also on filesystem, JVM implementation details, OS etc.Eg. on Android File.exists() is implemented using access() system call while File.isFile()/File.isDirectory() use stat(). In this case processing stat() output requires more logic in userspace than access().
http://stackoverflow.com/a/38620520/6952713
0 0
- java File中File.exists() 与 File.isFile()区别?
- java.io.file.isfile与exists区别
- Java isfile()与exists()的区别
- Java isfile()与exists()的区别
- File.Exists与Directory.Exists
- Java中new File("."),new File(""),new File(".."),new File(".\\")的区别
- Creating mailbox file: File exists
- Creating mailbox file: File exists
- C++中头文件File.h与File的区别
- file!=null和file.exists()的区别
- java开发:file.delete()与file.deleteOnExit()的区别
- java.io.File类中mkdir()与mkdirs()区别
- java.io.File类中mkdir()与mkdirs()区别
- java.io.File类中mkdir()与mkdirs()区别
- Java.Io.File中pathSeparator与separator的区别
- java自学,File类中String[] list()与File[] listFiles()
- file.delete()与file.deleteOnExit(); 的区别
- java.io.File中File.separator和File.pathSeparator的区别
- 对StringGrid输入一个数后对其他表格填充的代码
- rsync同步文件
- dom4j处理xml文件,读取xml字符串,格式化xml文件
- SOA、SOAP、RPC、REST、DUBBO的区别与联系
- Error:Execution failed for task ':app:mergeDebugResources'. > Error: java.util.concurrent.ExecutionE
- java File中File.exists() 与 File.isFile()区别?
- 使用sessionstorage解决微信网页返回保留原状态的问题
- 排序算法——插入排序
- JVM研究之观测工具jstat详解
- TextVeiw 的自定义View
- java web的介绍
- SDNU 1217.CD收藏 并查集
- JEECG再创新举,开辟支付宝服务窗开发新时代,业内独家培训 《支付宝服务窗实战培训》
- robotframework运行时后台报错UnicodeDecodeError