File.isFile()和File.isDirectory()都返回false [英] both File.isFile() and File.isDirectory() is returning false

查看:1363
本文介绍了File.isFile()和File.isDirectory()都返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为aaaäaa.xls的文件



为此, File.isFile() File.isDirectory()返回 false ?为什么它在 Linux 中返回 false

请尝试以下代码示例

  if(!pFile.exists()){
抛出新的FileNotFoundException();
}

boolean isDir = pFile.isDirectory();

boolean isFile = pfile.isFile();

该文件不是文件


如果它不是目录,并且另外满足其他系统相关标准


如果异常抛出,你必须检查文件路径。


I have a file with name "aaaäaa.xls"

For this, File.isFile() and File.isDirectory() is returning false? why it is returning false in Linux?

解决方案

Please try the following code example

if(!pFile.exists()){
   throw new FileNotFoundException();
}

boolean isDir = pFile.isDirectory();

boolean isFile = pfile.isFile();

the file is not a file

if it is not a directory and, in addition, satisfies other system-dependent criteria

if the exception is thrown, you have to check the file path.

这篇关于File.isFile()和File.isDirectory()都返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆