Hadoop dfs java客户端不工作
我刚刚开始学习hadoop。下面提到的是我连接hadoop hdfs的java代码Hadoop dfs java客户端不工作,hadoop,Hadoop,我刚刚开始学习hadoop。下面提到的是我连接hadoop hdfs的java代码 Configuration conf = new Configuration(); FileSystem fs = FileSystem.get(conf); BufferedReader reader = new BufferedReader(new InputStreamReader(fs.open(new Path("hdfs://localhost:54310"))));
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
BufferedReader reader = new BufferedReader(new InputStreamReader(fs.open(new Path("hdfs://localhost:54310"))));
String line = null;
line = reader.readLine();
while(line!=null){
System.out.println(line);
line = reader.readLine();
}
reader.close();
fs.close();
我说得有点错误hdfs://localhost:54310 不是有效的文件名。嗯,
hdfs://localhost:54310
是有效的文件名,但不是有效的文件名
您应该指定URI的路径部分:
new Path("hdfs://localhost:54310/path/to/your/file.txt")