文件fp =新文件(filePath); fp.exists()在Linux上没有正确的结果 [英] File fp = new File(filePath);fp.exists() does not yeild proper result on Linux

查看:107
本文介绍了文件fp =新文件(filePath); fp.exists()在Linux上没有正确的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面给出了检查文件是否存在的代码。

此代码适用于Windows但在Linux上即使存在文件也会失败。


如果您有解决方案或解决此问题,请告诉我。

有没有人遇到同样的问题。


布尔值DoesTheFileExist(String filePath)

{

文件fp =新文件(filePath);

if(true == fp.exists())

{

返回true;

}

其他

{

返回false;

}

}


问候,

Ganesh

Below given is the code to check if a file exists.
This code works on Windows but on Linux it fails even when the file exists.

Please let me know if you have a solution or a work around for this.
Has anybody experienced the same problem.

boolean DoesTheFileExist(String filePath)
{
File fp = new File(filePath);
if(true == fp.exists())
{
return true;
}
else
{
return false;
}
}

Regards,
Ganesh

推荐答案

它应该有效。当然是UNIX!= Windows。您应该仔细查看传递给此方法的路径。顺便说一下,你可以把它简单地写成
It should work. Of course UNIX != Windows. You should take a long look at the path you are passing to this method. By the way, you could have written it more simply as
展开 | 选择 | Wrap | 行号


可能是斜杠与反斜杠问题吗?


Jos
Could it be a slash versus backslash issue?

kind regards,

Jos


我认为乔斯是对的。当你在语法方面使用windows和linux时会出现一些问题。猜你最好检查一下linux的文档。



P.S. 星际争霸II即将推出...... En taro adun !!!


问候,

杰夫
I think Jos is right. there are some problems that occur when your using windows and linux in terms of syntax. guess you better check the documentation for linux.


P.S. StarCraft II coming soon... En taro adun !!!


Regards,
Jeff


这篇关于文件fp =新文件(filePath); fp.exists()在Linux上没有正确的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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