Java Hadoop JAr中的newFolderPath=Path.mergePath(workingDir,newFolderPath)

Java Hadoop JAr中的newFolderPath=Path.mergePath(workingDir,newFolderPath),java,hadoop,Java,Hadoop,我将使用hadoop jar编写hdfs。这是我的密码: import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; public class WriteInrix { public static void main(String[] args) throws Exception { FileS

我将使用hadoop jar编写hdfs。这是我的密码:

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

public class WriteInrix {
    public static void main(String[] args) throws Exception {
        FileSystem hdfs = FileSystem.get(new Configuration());
        Path homeDir = hdfs.getHomeDirectory();
        System.out.println("Home folder -" + homeDir);
        Path workingDir = hdfs.getWorkingDirectory();
        System.out.println(workingDir);

        Path newFolderPath = new Path("/MyDataFolder");
        newFolderPath = Path.mergePaths(workingDir, newFolderPath);

        if (hdfs.exists(newFolderPath)) {
            hdfs.delete(newFolderPath, true);
        }

        hdfs.mkdirs(newFolderPath);

        Path localFilePath = new Path("test.csv");
        Path hdfsFilePath = new Path(newFolderPath + "test1.csv");
        hdfs.copyFromLocalFile(localFilePath, hdfsFilePath);
    }
}
这里的问题在
newFolderPath=Path.mergepath(workingDir,newFolderPath)行中
此行给出一个错误,因为
Path
没有任何
mergePaths()
的定义。但是我从可靠的来源复制了代码。有什么问题吗?我应该使用什么替代方法?

我想知道您得到的确切错误。从您的代码来看,唯一让我印象深刻的是您是否应该这样做:

Path homeDir = new Path(hdfs.getHomeDirectory());

Path workingDir = new Path(hdfs.getWorkingDirectory());

我刚刚开始学习Java/Hadoop,所以我可能错了。请让我知道这是否有效。

我想知道您得到的确切错误。从您的代码来看,唯一让我印象深刻的是您是否应该这样做:

Path homeDir = new Path(hdfs.getHomeDirectory());

Path workingDir = new Path(hdfs.getWorkingDirectory());

我刚刚开始学习Java/Hadoop,所以我可能错了。请让我知道这是否有效。

您应该提供实际的stacktrace和stdout消息。您应该提供实际的stacktrace和stdout消息。我面临相同的错误,但上面的解决方案不起作用。我面临相同的错误,但上面的解决方案不起作用