hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richards Peter <hbkricha...@gmail.com>
Subject Determine absolute path of a file in hdfs
Date Wed, 09 Dec 2015 08:12:28 GMT

I have a situation where I need to determine the absolute path of a file in
hadoop as a String. The path should exclude the schema and authority. Eg:

I found the following option in hadoop api:

The aforementioned api returns a Path object. I do not want a new Path
object. Instead I would like to obtain the path as a String.

If I have the original path stored in a variable path (Path path), will
path.toUri().getPath() be sufficient to retrieve the intended path as a
String? I tried to obtain the path using this approach and I found it to
work fine for the cases that I tested. But I would like to take a
confirmation before I incorporate the code to my project.

Could you please confirm whether my approach is fine?

Richards Peter.

View raw message