Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Java查找hdfs中是否存在该文件?_Java_Maven_Hdfs_Hadoop2 - Fatal编程技术网

如何使用Java查找hdfs中是否存在该文件?

如何使用Java查找hdfs中是否存在该文件?,java,maven,hdfs,hadoop2,Java,Maven,Hdfs,Hadoop2,我正在尝试查找hdfs目录中是否存在触发器文件 代码: 不确定为什么会发生这种情况,\u TRIG1、\u TRIG2和\u TRIG3存在,而as\u TRIG4和\u TRIG5不存在。对于所有的触发器文件,结果都是一样的。帮助。从官方文档中,您可以通过直接内部调用来检查所需文件是否存在:@see 您的java代码看起来不错。也许你的if测试没有做好: if (!hdfs.exists(path)) { // <=================== @see the change a

我正在尝试查找hdfs目录中是否存在触发器文件

代码:


不确定为什么会发生这种情况,
\u TRIG1
\u TRIG2
\u TRIG3
存在,而as
\u TRIG4
\u TRIG5
不存在。对于所有的触发器文件,结果都是一样的。帮助。

从官方文档中,您可以通过直接内部调用来检查所需文件是否存在:@see

您的java代码看起来不错。也许你的if测试没有做好:

if (!hdfs.exists(path)) { // <=================== @see the change and test it.

如果(!hdfs.exists(path)){/来自官方文档,您可以通过直接内部调用检查您需要的文件是否存在:@see

您的java代码看起来不错。可能您的if测试编写得不好:

if (!hdfs.exists(path)) { // <=================== @see the change and test it.

如果(!hdfs.exists(path)){//Hello,也许你可以跟着它走:Hello,也许你可以跟着它走:
test

Usage: hadoop fs -test -[defswrz] URI

Options:

    -d: f the path is a directory, return 0.
    -e: if the path exists, return 0.
    -f: if the path is a file, return 0.
    -s: if the path is not empty, return 0.
    -w: if the path exists and write permission is granted, return 0.
    -r: if the path exists and read permission is granted, return 0.
    -z: if the file is zero length, return 0.

Example:

    hadoop fs -test -e filename
if (!hdfs.exists(path)) { // <=================== @see the change and test it.