Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
MapReduce >> mail # user >> Converting a Path to a full URI String and preserving special characters


Copy link to this message
-
Converting a Path to a full URI String and preserving special characters
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.
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB