1

I'm trying to pass string like that "hdfs://some_address/user/folder_with_files" to Paths.get method.

Unfortunately as a result i always get "hdfs:/some_address/user/folder_with_files" instead of "hdfs://.....".

Escape characters doesn't work (////) and I'm restricted to do this with Paths.get method.

Any idea?

UnderNotic
  • 345
  • 5
  • 16
  • I have no experience with this, but it looks like you're trying to access an address. Are you sure it's Paths.get you need, and not a file transfer protocol? – Clark Kent Dec 21 '15 at 14:16
  • I'm sure, because Paths.get is used in internal jar implementation and i cannot change this. – UnderNotic Dec 21 '15 at 14:18
  • `Paths.get` is only for filesystem paths. What you have here is a **URL**, not a filesystem path. What operating system are you running on? – RealSkeptic Dec 21 '15 at 14:20
  • this jar is executed on unix-based system, and this address points to directory in hdfs file system. – UnderNotic Dec 21 '15 at 14:22
  • 1
    Well, you'll need to mount the file system to some point in the directory tree on the unix system, and then you'll be able to use the mount point as the entry point to `Paths.get`. – RealSkeptic Dec 21 '15 at 14:23

1 Answers1

0

The easiest way to create your object from a String is to use an URL object. For example

String locationURL = "hdfs://some_address";
int id = 2345;
URL baseUrl = new URL(locationURL);

return new URL(baseUrl, String.format("/claims/%d", id)).toString();
Oleg Ushakov
  • 1,200
  • 14
  • 27