Jonas
Jonas

Reputation: 37

get the path of a resource in Java and get a path that can be opened in Browser with Special Characters

I'm doing Selenium Tests and I want to open a Resource in Java Code like that :

getClass().getClassLoader().getResource("fileWith[]");

The file I have to open contains '[' and ']' in its filename. I can't change the name.

If I call

url.getPath();

I get some String with '%5b' and '%5d' which I can't open in the Browser.

Which Encoding do I have to do to open the path in the Browser on Windows?

Upvotes: 0

Views: 103

Answers (1)

Raghuveer
Raghuveer

Reputation: 3057

The charaters that you see is URLEncoded you have to decode the values and you should be fine. For testing purpose you could use link.

The reason why you are not able to open the file is because there is no file with that name (fileWithURLEncodedValues).

Upvotes: 1

Related Questions