hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Public Network Services <publicnetworkservi...@gmail.com>
Subject Converting a Path to a full URI String and preserving special characters
Date Thu, 08 Aug 2013 23:54:30 GMT
Is there a reliable way of converting an HDFS Path object into a String?

Invoking path.toUri().toString() does not work with special characters
(e.g., if there are spaces in the original path string). So, for instance,
in the following example

String address = ...; // Path string without the hdfs://.../ prefix and
with special characters
Path path = new Path(address);
String pathString = path.toString();

the string variables "address" and "pathString" are not identical.

What I am after is a way to always get the full URL (including the
hdfs://.../ prefix) from a string address converted to a path and then back
to a string, even if the original address did not include the the
hdfs://.../ prefix.

My impression was that this is done via path.toString() all the time, but I
am getting some results where this is not the case.

View raw message