hadoop jarを使用してhdfsに書き込む予定です。ここに私のコードです:newFolderPath = HadoopのPath.mergePaths(workingDir、newFolderPath)JAr
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.mergePaths(workingDir, newFolderPath);
です。 Path
にはmergePaths()
の定義がないため、この行にエラーがあります。しかし、私は信頼できるソースからコードをコピーしました。どうしたの?どのような代替手段をとるべきですか?
実際のスタックトレースとstdoutメッセージを提供する必要があります。 –